DEV: Take 2 Queue jobs in tests by default.
On my machine this cuts the time taken to run our test suite from ~11mins to ~9mins.
This commit is contained in:
parent
56e9ff6853
commit
7fc8a36529
|
@ -22,6 +22,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
|
||||||
let(:reset_trigger) { DiscourseNarrativeBot::TrackSelector.reset_trigger }
|
let(:reset_trigger) { DiscourseNarrativeBot::TrackSelector.reset_trigger }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
SiteSetting.discourse_narrative_bot_enabled = true
|
SiteSetting.discourse_narrative_bot_enabled = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ describe DiscourseNarrativeBot::NewUserNarrative do
|
||||||
let(:reset_trigger) { DiscourseNarrativeBot::TrackSelector.reset_trigger }
|
let(:reset_trigger) { DiscourseNarrativeBot::TrackSelector.reset_trigger }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
SiteSetting.discourse_narrative_bot_enabled = true
|
SiteSetting.discourse_narrative_bot_enabled = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,10 @@ describe DiscourseNarrativeBot::TrackSelector do
|
||||||
end_message.chomp
|
end_message.chomp
|
||||||
end
|
end
|
||||||
|
|
||||||
|
before do
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
|
end
|
||||||
|
|
||||||
describe '#select' do
|
describe '#select' do
|
||||||
context 'in a PM with discobot' do
|
context 'in a PM with discobot' do
|
||||||
let(:first_post) { Fabricate(:post, user: discobot_user) }
|
let(:first_post) { Fabricate(:post, user: discobot_user) }
|
||||||
|
|
|
@ -4,7 +4,6 @@ describe "Discobot welcome post" do
|
||||||
let(:user) { Fabricate(:user) }
|
let(:user) { Fabricate(:user) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
SiteSetting.discourse_narrative_bot_enabled = true
|
SiteSetting.discourse_narrative_bot_enabled = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ describe User do
|
||||||
let(:profile_page_url) { "#{Discourse.base_url}/users/#{user.username}" }
|
let(:profile_page_url) { "#{Discourse.base_url}/users/#{user.username}" }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
SiteSetting.discourse_narrative_bot_enabled = true
|
SiteSetting.discourse_narrative_bot_enabled = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -78,7 +79,6 @@ describe User do
|
||||||
describe 'when welcome message is configured to be delayed' do
|
describe 'when welcome message is configured to be delayed' do
|
||||||
before do
|
before do
|
||||||
SiteSetting.discourse_narrative_bot_welcome_post_delay = 100
|
SiteSetting.discourse_narrative_bot_welcome_post_delay = 100
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should delay the welcome post until user logs in' do
|
it 'should delay the welcome post until user logs in' do
|
||||||
|
|
|
@ -207,8 +207,6 @@ describe Auth::GithubAuthenticator do
|
||||||
describe 'avatar retrieval' do
|
describe 'avatar retrieval' do
|
||||||
let(:job_klass) { Jobs::DownloadAvatarFromUrl }
|
let(:job_klass) { Jobs::DownloadAvatarFromUrl }
|
||||||
|
|
||||||
before { SiteSetting.queue_jobs = true }
|
|
||||||
|
|
||||||
context 'when user has a custom avatar' do
|
context 'when user has a custom avatar' do
|
||||||
let(:user_avatar) { Fabricate(:user_avatar, custom_upload: Fabricate(:upload)) }
|
let(:user_avatar) { Fabricate(:user_avatar, custom_upload: Fabricate(:upload)) }
|
||||||
let(:user_with_custom_avatar) { Fabricate(:user, user_avatar: user_avatar) }
|
let(:user_with_custom_avatar) { Fabricate(:user, user_avatar: user_avatar) }
|
||||||
|
|
|
@ -389,7 +389,6 @@ describe Email::Receiver do
|
||||||
|
|
||||||
it "supports attached images in TEXT part" do
|
it "supports attached images in TEXT part" do
|
||||||
SiteSetting.incoming_email_prefer_html = false
|
SiteSetting.incoming_email_prefer_html = false
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
|
|
||||||
expect { process(:no_body_with_image) }.to change { topic.posts.count }
|
expect { process(:no_body_with_image) }.to change { topic.posts.count }
|
||||||
expect(topic.posts.last.raw).to match(/<img/)
|
expect(topic.posts.last.raw).to match(/<img/)
|
||||||
|
@ -399,7 +398,6 @@ describe Email::Receiver do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "supports attached images in HTML part" do
|
it "supports attached images in HTML part" do
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
SiteSetting.incoming_email_prefer_html = true
|
SiteSetting.incoming_email_prefer_html = true
|
||||||
|
|
||||||
expect { process(:inline_image) }.to change { topic.posts.count }
|
expect { process(:inline_image) }.to change { topic.posts.count }
|
||||||
|
|
|
@ -266,7 +266,6 @@ describe PostCreator do
|
||||||
it 'creates a post with featured link' do
|
it 'creates a post with featured link' do
|
||||||
SiteSetting.topic_featured_link_enabled = true
|
SiteSetting.topic_featured_link_enabled = true
|
||||||
SiteSetting.min_first_post_length = 100
|
SiteSetting.min_first_post_length = 100
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
|
|
||||||
post = creator_with_featured_link.create
|
post = creator_with_featured_link.create
|
||||||
expect(post.topic.featured_link).to eq('http://www.discourse.org')
|
expect(post.topic.featured_link).to eq('http://www.discourse.org')
|
||||||
|
@ -290,10 +289,6 @@ describe PostCreator do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "topic's auto close" do
|
describe "topic's auto close" do
|
||||||
before do
|
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
end
|
|
||||||
|
|
||||||
it "doesn't update topic's auto close when it's not based on last post" do
|
it "doesn't update topic's auto close when it's not based on last post" do
|
||||||
freeze_time
|
freeze_time
|
||||||
|
|
||||||
|
@ -838,6 +833,8 @@ describe PostCreator do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'can post to a group correctly' do
|
it 'can post to a group correctly' do
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
|
|
||||||
expect(post.topic.archetype).to eq(Archetype.private_message)
|
expect(post.topic.archetype).to eq(Archetype.private_message)
|
||||||
expect(post.topic.topic_allowed_users.count).to eq(1)
|
expect(post.topic.topic_allowed_users.count).to eq(1)
|
||||||
expect(post.topic.topic_allowed_groups.count).to eq(1)
|
expect(post.topic.topic_allowed_groups.count).to eq(1)
|
||||||
|
|
|
@ -521,6 +521,7 @@ describe PostDestroyer do
|
||||||
|
|
||||||
context '@mentions' do
|
context '@mentions' do
|
||||||
it 'removes notifications when deleted' do
|
it 'removes notifications when deleted' do
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
user = Fabricate(:evil_trout)
|
user = Fabricate(:evil_trout)
|
||||||
post = create_post(raw: 'Hello @eviltrout')
|
post = create_post(raw: 'Hello @eviltrout')
|
||||||
expect {
|
expect {
|
||||||
|
|
|
@ -570,6 +570,10 @@ describe PostRevisor do
|
||||||
|
|
||||||
let(:mentioned_user) { Fabricate(:user) }
|
let(:mentioned_user) { Fabricate(:user) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
|
end
|
||||||
|
|
||||||
it "generates a notification for a mention" do
|
it "generates a notification for a mention" do
|
||||||
expect {
|
expect {
|
||||||
subject.revise!(Fabricate(:user), raw: "Random user is mentioning @#{mentioned_user.username_lower}")
|
subject.revise!(Fabricate(:user), raw: "Random user is mentioning @#{mentioned_user.username_lower}")
|
||||||
|
|
|
@ -83,7 +83,6 @@ describe Admin::EmailController do
|
||||||
context '#handle_mail' do
|
context '#handle_mail' do
|
||||||
before do
|
before do
|
||||||
log_in_user(Fabricate(:admin))
|
log_in_user(Fabricate(:admin))
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should enqueue the right job' do
|
it 'should enqueue the right job' do
|
||||||
|
|
|
@ -10,6 +10,7 @@ describe CategoriesController do
|
||||||
|
|
||||||
describe "logged in" do
|
describe "logged in" do
|
||||||
before do
|
before do
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
@user = log_in(:admin)
|
@user = log_in(:admin)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -49,8 +50,6 @@ describe CategoriesController do
|
||||||
}, format: :json
|
}, format: :json
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.not_to respond_with(:success) }
|
|
||||||
|
|
||||||
it "returns errors on a duplicate category name" do
|
it "returns errors on a duplicate category name" do
|
||||||
expect(response.status).to eq(422)
|
expect(response.status).to eq(422)
|
||||||
end
|
end
|
||||||
|
@ -157,6 +156,9 @@ describe CategoriesController do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "update" do
|
describe "update" do
|
||||||
|
before do
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
|
end
|
||||||
|
|
||||||
it "requires the user to be logged in" do
|
it "requires the user to be logged in" do
|
||||||
put :update, params: { id: 'category' }, format: :json
|
put :update, params: { id: 'category' }, format: :json
|
||||||
|
|
|
@ -28,7 +28,6 @@ describe Topic do
|
||||||
|
|
||||||
context 'jobs may be queued' do
|
context 'jobs may be queued' do
|
||||||
before do
|
before do
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
freeze_time
|
freeze_time
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -163,6 +163,7 @@ describe WatchedWord do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "flags on revisions" do
|
it "flags on revisions" do
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
post = Fabricate(:post, topic: Fabricate(:topic, user: tl2_user), user: tl2_user)
|
post = Fabricate(:post, topic: Fabricate(:topic, user: tl2_user), user: tl2_user)
|
||||||
expect {
|
expect {
|
||||||
PostRevisor.new(post).revise!(post.user, { raw: "Want some #{flag_word.word} for cheap?" }, revised_at: post.updated_at + 10.seconds)
|
PostRevisor.new(post).revise!(post.user, { raw: "Want some #{flag_word.word} for cheap?" }, revised_at: post.updated_at + 10.seconds)
|
||||||
|
|
|
@ -9,10 +9,6 @@ describe Jobs::DeleteTopic do
|
||||||
|
|
||||||
let(:first_post) { create_post(topic: topic) }
|
let(:first_post) { create_post(topic: topic) }
|
||||||
|
|
||||||
before do
|
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
end
|
|
||||||
|
|
||||||
it "can delete a topic" do
|
it "can delete a topic" do
|
||||||
first_post
|
first_post
|
||||||
|
|
||||||
|
|
|
@ -76,8 +76,6 @@ describe Jobs do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'deletes the matching job' do
|
it 'deletes the matching job' do
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
|
|
||||||
Sidekiq::Testing.disable! do
|
Sidekiq::Testing.disable! do
|
||||||
expect(scheduled_jobs.size).to eq(0)
|
expect(scheduled_jobs.size).to eq(0)
|
||||||
|
|
||||||
|
|
|
@ -16,10 +16,6 @@ RSpec.describe Jobs::PublishTopicToCategory do
|
||||||
topic
|
topic
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'when topic has been deleted' do
|
describe 'when topic has been deleted' do
|
||||||
it 'should not publish the topic to the new category' do
|
it 'should not publish the topic to the new category' do
|
||||||
freeze_time 1.hour.ago
|
freeze_time 1.hour.ago
|
||||||
|
|
|
@ -32,6 +32,7 @@ describe Jobs::PullHotlinkedImages do
|
||||||
|
|
||||||
describe '#execute' do
|
describe '#execute' do
|
||||||
before do
|
before do
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
FastImage.expects(:size).returns([100, 100]).at_least_once
|
FastImage.expects(:size).returns([100, 100]).at_least_once
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,6 @@ describe Jobs::ToggleTopicClosed do
|
||||||
Fabricate(:topic_timer, user: admin).topic
|
Fabricate(:topic_timer, user: admin).topic
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should be able to close a topic' do
|
it 'should be able to close a topic' do
|
||||||
topic
|
topic
|
||||||
|
|
||||||
|
|
|
@ -10,10 +10,6 @@ describe Jobs::TopicReminder do
|
||||||
).topic
|
).topic
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should be able to create a reminder" do
|
it "should be able to create a reminder" do
|
||||||
topic_timer = topic.topic_timers.first
|
topic_timer = topic.topic_timers.first
|
||||||
freeze_time 1.day.from_now
|
freeze_time 1.day.from_now
|
||||||
|
|
|
@ -68,6 +68,7 @@ describe CategoryUser do
|
||||||
|
|
||||||
context 'integration' do
|
context 'integration' do
|
||||||
before do
|
before do
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
NotificationEmailer.enable
|
NotificationEmailer.enable
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ describe DiscourseSingleSignOn do
|
||||||
SiteSetting.sso_url = @sso_url
|
SiteSetting.sso_url = @sso_url
|
||||||
SiteSetting.enable_sso = true
|
SiteSetting.enable_sso = true
|
||||||
SiteSetting.sso_secret = @sso_secret
|
SiteSetting.sso_secret = @sso_secret
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
end
|
end
|
||||||
|
|
||||||
def make_sso
|
def make_sso
|
||||||
|
|
|
@ -429,7 +429,6 @@ describe PostAction do
|
||||||
post = create_post
|
post = create_post
|
||||||
walterwhite = Fabricate(:walter_white)
|
walterwhite = Fabricate(:walter_white)
|
||||||
|
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
SiteSetting.flags_required_to_hide_post = 2
|
SiteSetting.flags_required_to_hide_post = 2
|
||||||
Discourse.stubs(:site_contact_user).returns(admin)
|
Discourse.stubs(:site_contact_user).returns(admin)
|
||||||
|
|
||||||
|
@ -658,6 +657,7 @@ describe PostAction do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should create a notification in the related topic" do
|
it "should create a notification in the related topic" do
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
post = Fabricate(:post)
|
post = Fabricate(:post)
|
||||||
user = Fabricate(:user)
|
user = Fabricate(:user)
|
||||||
action = PostAction.act(user, post, PostActionType.types[:spam], message: "WAT")
|
action = PostAction.act(user, post, PostActionType.types[:spam], message: "WAT")
|
||||||
|
|
|
@ -39,6 +39,7 @@ describe PostMover do
|
||||||
let(:p6) { Fabricate(:post, topic: topic) }
|
let(:p6) { Fabricate(:post, topic: topic) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
p1.replies << p3
|
p1.replies << p3
|
||||||
p2.replies << p4
|
p2.replies << p4
|
||||||
UserActionCreator.enable
|
UserActionCreator.enable
|
||||||
|
|
|
@ -2,6 +2,8 @@ require 'rails_helper'
|
||||||
|
|
||||||
describe QuotedPost do
|
describe QuotedPost do
|
||||||
it 'correctly extracts quotes' do
|
it 'correctly extracts quotes' do
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
|
|
||||||
topic = Fabricate(:topic)
|
topic = Fabricate(:topic)
|
||||||
post1 = create_post(topic: topic, post_number: 1, raw: "foo bar")
|
post1 = create_post(topic: topic, post_number: 1, raw: "foo bar")
|
||||||
post2 = create_post(topic: topic, post_number: 2, raw: "lorem ipsum")
|
post2 = create_post(topic: topic, post_number: 2, raw: "lorem ipsum")
|
||||||
|
|
|
@ -74,6 +74,9 @@ describe TagUser do
|
||||||
let(:tracked_tag) { Fabricate(:tag) }
|
let(:tracked_tag) { Fabricate(:tag) }
|
||||||
|
|
||||||
context "with some tag notification settings" do
|
context "with some tag notification settings" do
|
||||||
|
before do
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
|
end
|
||||||
|
|
||||||
let :watched_post do
|
let :watched_post do
|
||||||
TagUser.create!(user: user, tag: watched_tag, notification_level: TagUser.notification_levels[:watching])
|
TagUser.create!(user: user, tag: watched_tag, notification_level: TagUser.notification_levels[:watching])
|
||||||
|
|
|
@ -1214,6 +1214,8 @@ describe Topic do
|
||||||
|
|
||||||
describe 'user that is watching the new category' do
|
describe 'user that is watching the new category' do
|
||||||
it 'should generate the notification for the topic' do
|
it 'should generate the notification for the topic' do
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
|
|
||||||
topic.posts << Fabricate(:post)
|
topic.posts << Fabricate(:post)
|
||||||
|
|
||||||
CategoryUser.set_notification_level_for_category(
|
CategoryUser.set_notification_level_for_category(
|
||||||
|
@ -1269,7 +1271,6 @@ describe Topic do
|
||||||
|
|
||||||
describe 'when topic is already closed' do
|
describe 'when topic is already closed' do
|
||||||
before do
|
before do
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
topic.update_status('closed', true, Discourse.system_user)
|
topic.update_status('closed', true, Discourse.system_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1519,6 +1520,8 @@ describe Topic do
|
||||||
let(:topic) { Fabricate(:topic, category: category) }
|
let(:topic) { Fabricate(:topic, category: category) }
|
||||||
|
|
||||||
it "should be able to override category's default auto close" do
|
it "should be able to override category's default auto close" do
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
|
|
||||||
expect(topic.topic_timers.first.duration).to eq(4)
|
expect(topic.topic_timers.first.duration).to eq(4)
|
||||||
|
|
||||||
topic.set_or_create_timer(TopicTimer.types[:close], 2, by_user: admin)
|
topic.set_or_create_timer(TopicTimer.types[:close], 2, by_user: admin)
|
||||||
|
|
|
@ -176,6 +176,10 @@ RSpec.describe TopicTimer, type: :model do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
before do
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
|
end
|
||||||
|
|
||||||
it 'should close the topic' do
|
it 'should close the topic' do
|
||||||
topic_timer
|
topic_timer
|
||||||
expect(topic.reload.closed).to eq(true)
|
expect(topic.reload.closed).to eq(true)
|
||||||
|
@ -201,6 +205,10 @@ RSpec.describe TopicTimer, type: :model do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
before do
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
|
end
|
||||||
|
|
||||||
it 'should open the topic' do
|
it 'should open the topic' do
|
||||||
topic_timer
|
topic_timer
|
||||||
expect(topic.reload.closed).to eq(false)
|
expect(topic.reload.closed).to eq(false)
|
||||||
|
@ -239,10 +247,6 @@ RSpec.describe TopicTimer, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.ensure_consistency!' do
|
describe '.ensure_consistency!' do
|
||||||
before do
|
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should enqueue jobs that have been missed' do
|
it 'should enqueue jobs that have been missed' do
|
||||||
close_topic_timer = Fabricate(:topic_timer,
|
close_topic_timer = Fabricate(:topic_timer,
|
||||||
execute_at: Time.zone.now - 1.hour,
|
execute_at: Time.zone.now - 1.hour,
|
||||||
|
|
|
@ -437,6 +437,7 @@ describe TopicUser do
|
||||||
it "will receive email notification for every topic" do
|
it "will receive email notification for every topic" do
|
||||||
user1 = Fabricate(:user)
|
user1 = Fabricate(:user)
|
||||||
|
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
SiteSetting.default_email_mailing_list_mode = true
|
SiteSetting.default_email_mailing_list_mode = true
|
||||||
SiteSetting.default_email_mailing_list_mode_frequency = 1
|
SiteSetting.default_email_mailing_list_mode_frequency = 1
|
||||||
|
|
||||||
|
|
|
@ -1066,6 +1066,7 @@ describe User do
|
||||||
|
|
||||||
context "with a reply" do
|
context "with a reply" do
|
||||||
before do
|
before do
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
PostCreator.new(Fabricate(:user),
|
PostCreator.new(Fabricate(:user),
|
||||||
raw: 'whatever this is a raw post',
|
raw: 'whatever this is a raw post',
|
||||||
topic_id: topic.id,
|
topic_id: topic.id,
|
||||||
|
@ -1237,7 +1238,6 @@ describe User do
|
||||||
describe "refresh_avatar" do
|
describe "refresh_avatar" do
|
||||||
it "enqueues the update_gravatar job when automatically downloading gravatars" do
|
it "enqueues the update_gravatar job when automatically downloading gravatars" do
|
||||||
SiteSetting.automatically_download_gravatars = true
|
SiteSetting.automatically_download_gravatars = true
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
|
|
||||||
user = Fabricate(:user)
|
user = Fabricate(:user)
|
||||||
|
|
||||||
|
|
|
@ -80,10 +80,6 @@ describe WebHook do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#enqueue_hooks' do
|
describe '#enqueue_hooks' do
|
||||||
before do
|
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'accepts additional parameters' do
|
it 'accepts additional parameters' do
|
||||||
payload = { test: 'some payload' }.to_json
|
payload = { test: 'some payload' }.to_json
|
||||||
WebHook.enqueue_hooks(:post, payload: payload)
|
WebHook.enqueue_hooks(:post, payload: payload)
|
||||||
|
@ -125,7 +121,6 @@ describe WebHook do
|
||||||
let(:topic_web_hook) { Fabricate(:topic_web_hook) }
|
let(:topic_web_hook) { Fabricate(:topic_web_hook) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
topic_web_hook
|
topic_web_hook
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -158,6 +158,10 @@ RSpec.configure do |config|
|
||||||
# very expensive IO operations
|
# very expensive IO operations
|
||||||
SiteSetting.automatically_download_gravatars = false
|
SiteSetting.automatically_download_gravatars = false
|
||||||
|
|
||||||
|
# Running jobs are expensive and most of our tests are not concern with
|
||||||
|
# code that runs inside jobs
|
||||||
|
SiteSetting.queue_jobs = true
|
||||||
|
|
||||||
Discourse.clear_readonly!
|
Discourse.clear_readonly!
|
||||||
Sidekiq::Worker.clear_all
|
Sidekiq::Worker.clear_all
|
||||||
|
|
||||||
|
|
|
@ -36,12 +36,14 @@ RSpec.describe Admin::FlagsController do
|
||||||
context '#agree' do
|
context '#agree' do
|
||||||
it 'should work' do
|
it 'should work' do
|
||||||
SiteSetting.allow_user_locale = true
|
SiteSetting.allow_user_locale = true
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
|
|
||||||
post_action = PostAction.act(user, post_1, PostActionType.types[:spam], message: 'bad')
|
post_action = PostAction.act(user, post_1, PostActionType.types[:spam], message: 'bad')
|
||||||
admin.update!(locale: 'ja')
|
admin.update!(locale: 'ja')
|
||||||
|
|
||||||
post "/admin/flags/agree/#{post_1.id}.json"
|
post "/admin/flags/agree/#{post_1.id}.json"
|
||||||
|
|
||||||
expect(response).to be_success
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
post_action.reload
|
post_action.reload
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,8 @@ RSpec.describe Admin::GroupsController do
|
||||||
let(:user2) { Fabricate(:user, trust_level: 4) }
|
let(:user2) { Fabricate(:user, trust_level: 4) }
|
||||||
|
|
||||||
it "can assign users to a group by email or username" do
|
it "can assign users to a group by email or username" do
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
|
|
||||||
put "/admin/groups/bulk.json", params: {
|
put "/admin/groups/bulk.json", params: {
|
||||||
group_id: group.id, users: [user.username.upcase, user2.email, 'doesnt_exist']
|
group_id: group.id, users: [user.username.upcase, user2.email, 'doesnt_exist']
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,6 @@ RSpec.describe Admin::UsersController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should able to disable the second factor for another user' do
|
it 'should able to disable the second factor for another user' do
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
|
|
||||||
expect do
|
expect do
|
||||||
put "/admin/users/#{user.id}/disable_second_factor.json"
|
put "/admin/users/#{user.id}/disable_second_factor.json"
|
||||||
end.to change { Jobs::CriticalUserEmail.jobs.length }.by(1)
|
end.to change { Jobs::CriticalUserEmail.jobs.length }.by(1)
|
||||||
|
|
|
@ -80,6 +80,10 @@ describe EmbedController do
|
||||||
context "success" do
|
context "success" do
|
||||||
let(:headers) { { 'REFERER' => embed_url } }
|
let(:headers) { { 'REFERER' => embed_url } }
|
||||||
|
|
||||||
|
before do
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
expect(response).to be_success
|
expect(response).to be_success
|
||||||
expect(response.headers['X-Frame-Options']).to eq("ALLOWALL")
|
expect(response.headers['X-Frame-Options']).to eq("ALLOWALL")
|
||||||
|
|
|
@ -496,7 +496,6 @@ describe GroupsController do
|
||||||
before do
|
before do
|
||||||
user.update_attributes!(admin: true)
|
user.update_attributes!(admin: true)
|
||||||
sign_in(user)
|
sign_in(user)
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should be able to update the group' do
|
it 'should be able to update the group' do
|
||||||
|
|
|
@ -568,6 +568,7 @@ describe PostsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'allows to create posts in import_mode' do
|
it 'allows to create posts in import_mode' do
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
NotificationEmailer.enable
|
NotificationEmailer.enable
|
||||||
post_1 = Fabricate(:post)
|
post_1 = Fabricate(:post)
|
||||||
user = Fabricate(:user)
|
user = Fabricate(:user)
|
||||||
|
@ -782,8 +783,6 @@ describe PostsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'can create a reply to a post' do
|
it 'can create a reply to a post' do
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
|
|
||||||
topic = Fabricate(:private_message_post, user: user).topic
|
topic = Fabricate(:private_message_post, user: user).topic
|
||||||
post_2 = Fabricate(:private_message_post, user: user, topic: topic)
|
post_2 = Fabricate(:private_message_post, user: user, topic: topic)
|
||||||
|
|
||||||
|
|
|
@ -435,7 +435,6 @@ RSpec.describe SessionController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sends an activation email' do
|
it 'sends an activation email' do
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
sso = get_sso('/a/')
|
sso = get_sso('/a/')
|
||||||
sso.external_id = '666' # the number of the beast
|
sso.external_id = '666' # the number of the beast
|
||||||
sso.email = 'bob@bob.com'
|
sso.email = 'bob@bob.com'
|
||||||
|
@ -1200,7 +1199,6 @@ RSpec.describe SessionController do
|
||||||
|
|
||||||
context 'for a non existant username' do
|
context 'for a non existant username' do
|
||||||
it "doesn't generate a new token for a made up username" do
|
it "doesn't generate a new token for a made up username" do
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
expect do
|
expect do
|
||||||
post "/session/forgot_password.json", params: { login: 'made_up' }
|
post "/session/forgot_password.json", params: { login: 'made_up' }
|
||||||
end.not_to change(EmailToken, :count)
|
end.not_to change(EmailToken, :count)
|
||||||
|
@ -1238,7 +1236,6 @@ RSpec.describe SessionController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "enqueues an email" do
|
it "enqueues an email" do
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
post "/session/forgot_password.json", params: { login: user.username }
|
post "/session/forgot_password.json", params: { login: user.username }
|
||||||
expect(Jobs::CriticalUserEmail.jobs.size).to eq(1)
|
expect(Jobs::CriticalUserEmail.jobs.size).to eq(1)
|
||||||
end
|
end
|
||||||
|
@ -1254,7 +1251,6 @@ RSpec.describe SessionController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'enqueues no email' do
|
it 'enqueues no email' do
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
post "/session/forgot_password.json", params: { login: system.username }
|
post "/session/forgot_password.json", params: { login: system.username }
|
||||||
expect(Jobs::CriticalUserEmail.jobs.size).to eq(0)
|
expect(Jobs::CriticalUserEmail.jobs.size).to eq(0)
|
||||||
end
|
end
|
||||||
|
@ -1270,7 +1266,6 @@ RSpec.describe SessionController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'enqueues no email' do
|
it 'enqueues no email' do
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
post "/session/forgot_password.json", params: { login: staged.username }
|
post "/session/forgot_password.json", params: { login: staged.username }
|
||||||
expect(Jobs::CriticalUserEmail.jobs.size).to eq(0)
|
expect(Jobs::CriticalUserEmail.jobs.size).to eq(0)
|
||||||
end
|
end
|
||||||
|
|
|
@ -258,8 +258,6 @@ RSpec.describe TopicsController do
|
||||||
|
|
||||||
describe 'publishing topic to category in the future' do
|
describe 'publishing topic to category in the future' do
|
||||||
it 'should be able to create the topic status update' do
|
it 'should be able to create the topic status update' do
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
|
|
||||||
post "/t/#{topic.id}/timer.json", params: {
|
post "/t/#{topic.id}/timer.json", params: {
|
||||||
time: 24,
|
time: 24,
|
||||||
status_type: TopicTimer.types[3],
|
status_type: TopicTimer.types[3],
|
||||||
|
|
|
@ -25,10 +25,6 @@ describe UsersController do
|
||||||
|
|
||||||
context 'valid token' do
|
context 'valid token' do
|
||||||
context 'welcome message' do
|
context 'welcome message' do
|
||||||
before do
|
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'enqueues a welcome message if the user object indicates so' do
|
it 'enqueues a welcome message if the user object indicates so' do
|
||||||
user.update(active: false)
|
user.update(active: false)
|
||||||
put "/u/activate-account/#{token}"
|
put "/u/activate-account/#{token}"
|
||||||
|
@ -353,7 +349,6 @@ describe UsersController do
|
||||||
|
|
||||||
context 'enqueues mail' do
|
context 'enqueues mail' do
|
||||||
it 'enqueues mail with admin email and sso enabled' do
|
it 'enqueues mail with admin email and sso enabled' do
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
put "/u/admin-login", params: { email: admin.email }
|
put "/u/admin-login", params: { email: admin.email }
|
||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
expect(Jobs::CriticalUserEmail.jobs.size).to eq(1)
|
expect(Jobs::CriticalUserEmail.jobs.size).to eq(1)
|
||||||
|
@ -469,8 +464,7 @@ describe UsersController do
|
||||||
UsersController.any_instance.stubs(:honeypot_value).returns(nil)
|
UsersController.any_instance.stubs(:honeypot_value).returns(nil)
|
||||||
UsersController.any_instance.stubs(:challenge_value).returns(nil)
|
UsersController.any_instance.stubs(:challenge_value).returns(nil)
|
||||||
SiteSetting.allow_new_registrations = true
|
SiteSetting.allow_new_registrations = true
|
||||||
@user = Fabricate.build(:user)
|
@user = Fabricate.build(:user, password: "strongpassword")
|
||||||
@user.password = "strongpassword"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:post_user_params) do
|
let(:post_user_params) do
|
||||||
|
@ -524,8 +518,6 @@ describe UsersController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates a user correctly' do
|
it 'creates a user correctly' do
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
|
|
||||||
post_user
|
post_user
|
||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
expect(JSON.parse(response.body)['active']).to be_falsey
|
expect(JSON.parse(response.body)['active']).to be_falsey
|
||||||
|
@ -545,8 +537,6 @@ describe UsersController do
|
||||||
before { SiteSetting.must_approve_users = true }
|
before { SiteSetting.must_approve_users = true }
|
||||||
|
|
||||||
it 'creates a user correctly' do
|
it 'creates a user correctly' do
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
|
|
||||||
post_user
|
post_user
|
||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
|
@ -619,7 +609,6 @@ describe UsersController do
|
||||||
let(:api_key) { Fabricate(:api_key, user: admin) }
|
let(:api_key) { Fabricate(:api_key, user: admin) }
|
||||||
|
|
||||||
it "creates the user as active with a regular key" do
|
it "creates the user as active with a regular key" do
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
SiteSetting.send_welcome_message = true
|
SiteSetting.send_welcome_message = true
|
||||||
SiteSetting.must_approve_users = true
|
SiteSetting.must_approve_users = true
|
||||||
|
|
||||||
|
@ -700,7 +689,6 @@ describe UsersController do
|
||||||
before { User.any_instance.stubs(:active?).returns(true) }
|
before { User.any_instance.stubs(:active?).returns(true) }
|
||||||
|
|
||||||
it 'enqueues a welcome email' do
|
it 'enqueues a welcome email' do
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
User.any_instance.expects(:enqueue_welcome_message).with('welcome_user')
|
User.any_instance.expects(:enqueue_welcome_message).with('welcome_user')
|
||||||
|
|
||||||
post_user
|
post_user
|
||||||
|
@ -1598,7 +1586,8 @@ describe UsersController do
|
||||||
password: "strongpassword",
|
password: "strongpassword",
|
||||||
email: "dsdsds@sasa.com"
|
email: "dsdsds@sasa.com"
|
||||||
}
|
}
|
||||||
User.where(username: "osamatest").first
|
|
||||||
|
User.find_by(username: "osamatest")
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for an existing user' do
|
context 'for an existing user' do
|
||||||
|
@ -1698,10 +1687,12 @@ describe UsersController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should send an email' do
|
it 'should send an email' do
|
||||||
SiteSetting.queue_jobs = true
|
expect do
|
||||||
post "/u/action/send_activation_email.json", params: { username: user.username }
|
post "/u/action/send_activation_email.json", params: {
|
||||||
|
username: user.username
|
||||||
|
}
|
||||||
|
end.to change { Jobs::CriticalUserEmail.jobs.size }.by(1)
|
||||||
|
|
||||||
expect(Jobs::CriticalUserEmail.jobs.size).to eq(1)
|
|
||||||
expect(session[SessionController::ACTIVATE_USER_KEY]).to eq(nil)
|
expect(session[SessionController::ACTIVATE_USER_KEY]).to eq(nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1709,7 +1700,6 @@ describe UsersController do
|
||||||
|
|
||||||
context 'when username does not exist' do
|
context 'when username does not exist' do
|
||||||
it 'should not send an email' do
|
it 'should not send an email' do
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
post "/u/action/send_activation_email.json", params: { username: 'nopenopenopenope' }
|
post "/u/action/send_activation_email.json", params: { username: 'nopenopenopenope' }
|
||||||
expect(response.status).to eq(404)
|
expect(response.status).to eq(404)
|
||||||
expect(Jobs::CriticalUserEmail.jobs.size).to eq(0)
|
expect(Jobs::CriticalUserEmail.jobs.size).to eq(0)
|
||||||
|
@ -2691,7 +2681,6 @@ describe UsersController do
|
||||||
|
|
||||||
describe '#email_login' do
|
describe '#email_login' do
|
||||||
before do
|
before do
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
SiteSetting.enable_local_logins_via_email = true
|
SiteSetting.enable_local_logins_via_email = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,10 @@ require 'rails_helper'
|
||||||
RSpec.describe GroupMentionsUpdater do
|
RSpec.describe GroupMentionsUpdater do
|
||||||
let(:post) { Fabricate(:post) }
|
let(:post) { Fabricate(:post) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
|
end
|
||||||
|
|
||||||
describe '.update' do
|
describe '.update' do
|
||||||
it 'should update valid group mentions' do
|
it 'should update valid group mentions' do
|
||||||
new_group_name = 'awesome_team'
|
new_group_name = 'awesome_team'
|
||||||
|
|
|
@ -307,6 +307,10 @@ describe PostAlerter do
|
||||||
let(:user) { post1.user }
|
let(:user) { post1.user }
|
||||||
let(:linking_post) { create_post(raw: "my magic topic\n##{Discourse.base_url}#{post1.url}") }
|
let(:linking_post) { create_post(raw: "my magic topic\n##{Discourse.base_url}#{post1.url}") }
|
||||||
|
|
||||||
|
before do
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
|
end
|
||||||
|
|
||||||
it "will notify correctly on linking" do
|
it "will notify correctly on linking" do
|
||||||
linking_post
|
linking_post
|
||||||
|
|
||||||
|
@ -379,6 +383,10 @@ describe PostAlerter do
|
||||||
let(:mention_post) { create_post_with_alerts(user: user, raw: 'Hello @eviltrout') }
|
let(:mention_post) { create_post_with_alerts(user: user, raw: 'Hello @eviltrout') }
|
||||||
let(:topic) { mention_post.topic }
|
let(:topic) { mention_post.topic }
|
||||||
|
|
||||||
|
before do
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
|
end
|
||||||
|
|
||||||
it 'notifies a user' do
|
it 'notifies a user' do
|
||||||
expect {
|
expect {
|
||||||
mention_post
|
mention_post
|
||||||
|
@ -629,7 +637,6 @@ describe PostAlerter do
|
||||||
let(:topic) { mention_post.topic }
|
let(:topic) { mention_post.topic }
|
||||||
|
|
||||||
it "pushes nothing to suspended users" do
|
it "pushes nothing to suspended users" do
|
||||||
SiteSetting.queue_jobs = true
|
|
||||||
SiteSetting.allowed_user_api_push_urls = "https://site.com/push|https://site2.com/push"
|
SiteSetting.allowed_user_api_push_urls = "https://site.com/push|https://site2.com/push"
|
||||||
|
|
||||||
evil_trout.update_columns(suspended_till: 1.year.from_now)
|
evil_trout.update_columns(suspended_till: 1.year.from_now)
|
||||||
|
@ -647,6 +654,7 @@ describe PostAlerter do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "correctly pushes notifications if configured correctly" do
|
it "correctly pushes notifications if configured correctly" do
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
SiteSetting.allowed_user_api_push_urls = "https://site.com/push|https://site2.com/push"
|
SiteSetting.allowed_user_api_push_urls = "https://site.com/push|https://site2.com/push"
|
||||||
|
|
||||||
2.times do |i|
|
2.times do |i|
|
||||||
|
|
|
@ -120,6 +120,7 @@ describe UserAnonymizer do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "updates the avatar in posts" do
|
it "updates the avatar in posts" do
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
upload = Fabricate(:upload, user: user)
|
upload = Fabricate(:upload, user: user)
|
||||||
user.user_avatar = UserAvatar.new(user_id: user.id, custom_upload_id: upload.id)
|
user.user_avatar = UserAvatar.new(user_id: user.id, custom_upload_id: upload.id)
|
||||||
user.uploaded_avatar_id = upload.id # chosen in user preferences
|
user.uploaded_avatar_id = upload.id # chosen in user preferences
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe UsernameChanger do
|
describe UsernameChanger do
|
||||||
|
before do
|
||||||
|
SiteSetting.queue_jobs = false
|
||||||
|
end
|
||||||
|
|
||||||
describe '#change' do
|
describe '#change' do
|
||||||
let(:user) { Fabricate(:user) }
|
let(:user) { Fabricate(:user) }
|
||||||
|
|
Loading…
Reference in New Issue