mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 18:41:07 +08:00
DEV: Apply syntax_tree formatting to plugins/*
This commit is contained in:
@ -1,48 +1,43 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe "Discobot Certificate" do
|
||||
let(:user) { Fabricate(:user, name: 'Jeff Atwood') }
|
||||
let(:user) { Fabricate(:user, name: "Jeff Atwood") }
|
||||
|
||||
let(:params) {
|
||||
{
|
||||
date: Time.zone.now.strftime("%b %d %Y"),
|
||||
user_id: user.id
|
||||
}
|
||||
}
|
||||
let(:params) { { date: Time.zone.now.strftime("%b %d %Y"), user_id: user.id } }
|
||||
|
||||
describe 'when viewing the certificate' do
|
||||
describe 'when no logged in' do
|
||||
it 'should return the right response' do
|
||||
get '/discobot/certificate.svg', params: params
|
||||
describe "when viewing the certificate" do
|
||||
describe "when no logged in" do
|
||||
it "should return the right response" do
|
||||
get "/discobot/certificate.svg", params: params
|
||||
|
||||
expect(response.status).to eq(404)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when logged in' do
|
||||
before do
|
||||
sign_in(user)
|
||||
end
|
||||
describe "when logged in" do
|
||||
before { sign_in(user) }
|
||||
|
||||
it 'should return the right text' do
|
||||
stub_request(:get, /letter_avatar_proxy/).to_return(status: 200, body: 'http://test.localhost/cdn/avatar.png')
|
||||
it "should return the right text" do
|
||||
stub_request(:get, /letter_avatar_proxy/).to_return(
|
||||
status: 200,
|
||||
body: "http://test.localhost/cdn/avatar.png",
|
||||
)
|
||||
stub_request(:get, /avatar.png/).to_return(status: 200)
|
||||
|
||||
stub_request(:get, SiteSetting.site_logo_small_url)
|
||||
.to_return(status: 200)
|
||||
stub_request(:get, SiteSetting.site_logo_small_url).to_return(status: 200)
|
||||
|
||||
get '/discobot/certificate.svg', params: params
|
||||
get "/discobot/certificate.svg", params: params
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(response.body).to include('<svg')
|
||||
expect(response.body).to include(user.avatar_template.gsub('{size}', '250'))
|
||||
expect(response.body).to include("<svg")
|
||||
expect(response.body).to include(user.avatar_template.gsub("{size}", "250"))
|
||||
expect(response.body).to include(SiteSetting.site_logo_small_url)
|
||||
end
|
||||
|
||||
describe 'when params are missing' do
|
||||
describe "when params are missing" do
|
||||
it "should raise the right errors" do
|
||||
params.each do |key, _|
|
||||
get '/discobot/certificate.svg', params: params.except(key)
|
||||
get "/discobot/certificate.svg", params: params.except(key)
|
||||
expect(response.status).to eq(400)
|
||||
end
|
||||
end
|
||||
|
@ -3,40 +3,39 @@
|
||||
RSpec.describe "Discobot welcome post" do
|
||||
let(:user) { Fabricate(:user) }
|
||||
|
||||
before do
|
||||
SiteSetting.discourse_narrative_bot_enabled = true
|
||||
end
|
||||
before { SiteSetting.discourse_narrative_bot_enabled = true }
|
||||
|
||||
context 'when discourse_narrative_bot_welcome_post_delay is 0' do
|
||||
it 'should not delay the welcome post' do
|
||||
context "when discourse_narrative_bot_welcome_post_delay is 0" do
|
||||
it "should not delay the welcome post" do
|
||||
user
|
||||
expect { sign_in(user) }.to_not change { Jobs::NarrativeInit.jobs.count }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when discourse_narrative_bot_welcome_post_delay is greater than 0' do
|
||||
before do
|
||||
SiteSetting.discourse_narrative_bot_welcome_post_delay = 5
|
||||
end
|
||||
context "when discourse_narrative_bot_welcome_post_delay is greater than 0" do
|
||||
before { SiteSetting.discourse_narrative_bot_welcome_post_delay = 5 }
|
||||
|
||||
context 'when user logs in normally' do
|
||||
it 'should delay the welcome post until user logs in' do
|
||||
context "when user logs in normally" do
|
||||
it "should delay the welcome post until user logs in" do
|
||||
expect { sign_in(user) }.to change { Jobs::NarrativeInit.jobs.count }.by(1)
|
||||
expect(Jobs::NarrativeInit.jobs.first["args"].first["user_id"]).to eq(user.id)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when user redeems an invite' do
|
||||
let!(:invite) { Fabricate(:invite, invited_by: Fabricate(:admin), email: 'testing@gmail.com') }
|
||||
context "when user redeems an invite" do
|
||||
let!(:invite) do
|
||||
Fabricate(:invite, invited_by: Fabricate(:admin), email: "testing@gmail.com")
|
||||
end
|
||||
|
||||
it 'should delay the welcome post until the user logs in' do
|
||||
it "should delay the welcome post until the user logs in" do
|
||||
expect do
|
||||
put "/invites/show/#{invite.invite_key}.json", params: {
|
||||
username: 'somename',
|
||||
name: 'testing',
|
||||
password: 'verystrongpassword',
|
||||
email_token: invite.email_token
|
||||
}
|
||||
put "/invites/show/#{invite.invite_key}.json",
|
||||
params: {
|
||||
username: "somename",
|
||||
name: "testing",
|
||||
password: "verystrongpassword",
|
||||
email_token: invite.email_token,
|
||||
}
|
||||
end.to change { User.count }.by(1)
|
||||
|
||||
expect(Jobs::NarrativeInit.jobs.first["args"].first["user_id"]).to eq(User.last.id)
|
||||
@ -44,14 +43,12 @@ RSpec.describe "Discobot welcome post" do
|
||||
end
|
||||
end
|
||||
|
||||
context 'when user is staged' do
|
||||
context "when user is staged" do
|
||||
let(:staged_user) { Fabricate(:user, staged: true) }
|
||||
|
||||
before do
|
||||
SiteSetting.discourse_narrative_bot_welcome_post_type = 'welcome_message'
|
||||
end
|
||||
before { SiteSetting.discourse_narrative_bot_welcome_post_type = "welcome_message" }
|
||||
|
||||
it 'should not send welcome message' do
|
||||
it "should not send welcome message" do
|
||||
expect { staged_user }.to_not change { Jobs::SendDefaultWelcomeMessage.jobs.count }
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user