A platform for community discussion. Free, open, simple.
REFACTOR: Move `queue_jobs` out of `SiteSetting`
Robin Wardfa5a15868320
diff --git a/app/jobs/base.rb b/app/jobs/base.rbindex 746f325c094..b57abae3e20 100644--- a/app/jobs/base.rb+++ b/app/jobs/base.rb@@ -4,6 +4,22 @@ module JobsSidekiq::Stats.new.enqueuedend+ def self.run_later?+ !@run_immediately+ end++ def self.run_immediately?+ !!@run_immediately+ end++ def self.run_immediately!+ @run_immediately = true+ end++ def self.run_later!+ @run_immediately = false+ end+def self.last_job_performed_atSidekiq.redis do |r|int = r.get('last_job_perform_at')@@ -169,7 +185,7 @@ module Jobsdef perform(*args)opts = args.extract_options!.with_indifferent_access- if SiteSetting.queue_jobs?+ if Jobs.run_later?Sidekiq.redis do |r|r.set('last_job_perform_at', Time.now.to_i)end@@ -272,7 +288,7 @@ module Jobsend# If we are able to queue a job, do it- if SiteSetting.queue_jobs?+ if Jobs.run_later?hash = {'class' => klass,'args' => [opts]diff --git a/config/environments/test.rb b/config/environments/test.rbindex df30b744fbc..9186e924e00 100644--- a/config/environments/test.rb+++ b/config/environments/test.rb@@ -63,14 +63,12 @@ Discourse::Application.configure dos.set_regardless_of_locale(:crawl_images, false)s.set_regardless_of_locale(:download_remote_images_to_local, false)s.set_regardless_of_locale(:unique_posts_mins, 0)- # Running jobs are expensive and most of our tests are not concern with- # code that runs inside jobs- s.set_regardless_of_locale(:queue_jobs, true)# disable pluginsif ENV['LOAD_PLUGINS'] == '1's.set_regardless_of_locale(:discourse_narrative_bot_enabled, false)endend+SiteSetting.refresh!endenddiff --git a/config/site_settings.yml b/config/site_settings.ymlindex 9155d1292ea..123da3ea49b 100644--- a/config/site_settings.yml+++ b/config/site_settings.yml@@ -1395,9 +1395,6 @@ developer:port:hidden: truedefault: ""- queue_jobs:- hidden: true- default: trueenable_long_polling:client: truedefault: truediff --git a/lib/generators/plugin/templates/controller_spec.rb.erb b/lib/generators/plugin/templates/controller_spec.rb.erbindex c73e0a87e9b..15472e1e4b3 100644--- a/lib/generators/plugin/templates/controller_spec.rb.erb+++ b/lib/generators/plugin/templates/controller_spec.rb.erb@@ -2,7 +2,7 @@ require 'rails_helper'describe <%= name %>::ActionsController dobefore do- run_jobs_synchronously!+ Jobs.run_immediately!endit 'can list' dodiff --git a/plugins/discourse-local-dates/spec/models/post_spec.rb b/plugins/discourse-local-dates/spec/models/post_spec.rbindex 9591607cc93..b472e987291 100644--- a/plugins/discourse-local-dates/spec/models/post_spec.rb+++ b/plugins/discourse-local-dates/spec/models/post_spec.rb@@ -3,7 +3,7 @@ require 'rails_helper'describe Post dobefore do- run_jobs_synchronously!+ Jobs.run_immediately!enddescribe '#local_dates' dodiff --git a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rbindex 91b0c15255c..4b44326f437 100644--- a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb+++ b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb@@ -22,7 +22,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative dolet(:reset_trigger) { DiscourseNarrativeBot::TrackSelector.reset_trigger }before do- run_jobs_synchronously!+ Jobs.run_immediately!SiteSetting.discourse_narrative_bot_enabled = trueenddiff --git a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rbindex 7ecc7270765..7377d37ee30 100644--- a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb+++ b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb@@ -25,7 +25,7 @@ describe DiscourseNarrativeBot::NewUserNarrative dolet(:reset_trigger) { DiscourseNarrativeBot::TrackSelector.reset_trigger }before do- run_jobs_synchronously!+ Jobs.run_immediately!SiteSetting.discourse_narrative_bot_enabled = trueenddiff --git a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/track_selector_spec.rb b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/track_selector_spec.rbindex 4d76b065669..b023b935411 100644--- a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/track_selector_spec.rb+++ b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/track_selector_spec.rb@@ -37,7 +37,7 @@ describe DiscourseNarrativeBot::TrackSelector doendbefore do- run_jobs_synchronously!+ Jobs.run_immediately!enddescribe '#select' dodiff --git a/plugins/discourse-narrative-bot/spec/user_spec.rb b/plugins/discourse-narrative-bot/spec/user_spec.rbindex de52f0eafec..07eaee49190 100644--- a/plugins/discourse-narrative-bot/spec/user_spec.rb+++ b/plugins/discourse-narrative-bot/spec/user_spec.rb@@ -13,7 +13,7 @@ describe User doendbefore do- run_jobs_synchronously!+ Jobs.run_immediately!SiteSetting.discourse_narrative_bot_enabled = trueenddiff --git a/script/profile_db_generator.rb b/script/profile_db_generator.rbindex 37f757177d9..f75ba4910e3 100644--- a/script/profile_db_generator.rb+++ b/script/profile_db_generator.rb@@ -55,7 +55,7 @@ endrequire File.expand_path(File.dirname(__FILE__) + "/../config/environment")-SiteSetting.queue_jobs = false+Jobs.run_immediately!unless Rails.env == "profile"puts "This script should only be used in the profile environment"diff --git a/spec/components/post_creator_spec.rb b/spec/components/post_creator_spec.rbindex 0e609c93588..c82aae8d14e 100644--- a/spec/components/post_creator_spec.rb+++ b/spec/components/post_creator_spec.rb@@ -902,7 +902,7 @@ describe PostCreator doendit 'can post to a group correctly' do- run_jobs_synchronously!+ Jobs.run_immediately!expect(post.topic.archetype).to eq(Archetype.private_message)expect(post.topic.topic_allowed_users.count).to eq(1)diff --git a/spec/components/post_destroyer_spec.rb b/spec/components/post_destroyer_spec.rbindex d5da412659b..6971688fce7 100644--- a/spec/components/post_destroyer_spec.rb+++ b/spec/components/post_destroyer_spec.rb@@ -617,7 +617,7 @@ describe PostDestroyer docontext '@mentions' doit 'removes notifications when deleted' do- run_jobs_synchronously!+ Jobs.run_immediately!user = Fabricate(:evil_trout)post = create_post(raw: 'Hello @eviltrout')expect {diff --git a/spec/components/post_revisor_spec.rb b/spec/components/post_revisor_spec.rbindex d721692f261..1fc26a6fbdd 100644--- a/spec/components/post_revisor_spec.rb+++ b/spec/components/post_revisor_spec.rb@@ -608,7 +608,7 @@ describe PostRevisor dolet(:mentioned_user) { Fabricate(:user) }before do- run_jobs_synchronously!+ Jobs.run_immediately!endit "generates a notification for a mention" dodiff --git a/spec/integration/watched_words_spec.rb b/spec/integration/watched_words_spec.rbindex 7620237b1c5..646084da860 100644--- a/spec/integration/watched_words_spec.rb+++ b/spec/integration/watched_words_spec.rb@@ -163,7 +163,7 @@ describe WatchedWord doendit "flags on revisions" do- run_jobs_synchronously!+ Jobs.run_immediately!post = Fabricate(:post, topic: Fabricate(:topic, user: tl2_user), user: tl2_user)expect {PostRevisor.new(post).revise!(post.user, { raw: "Want some #{flag_word.word} for cheap?" }, revised_at: post.updated_at + 10.seconds)diff --git a/spec/jobs/jobs_spec.rb b/spec/jobs/jobs_spec.rbindex a058971ed1d..0922aa1aa4a 100644--- a/spec/jobs/jobs_spec.rb+++ b/spec/jobs/jobs_spec.rb@@ -5,9 +5,9 @@ describe Jobs dodescribe 'enqueue' do- describe 'when queue_jobs is true' do+ describe 'run_later!' dobefore do- SiteSetting.expects(:queue_jobs?).at_least_once.returns(true)+ Jobs.run_later!endit 'enqueues a job in sidekiq' do@@ -74,9 +74,9 @@ describe Jobs doendend- describe 'when queue_jobs is false' do+ describe 'run_immediately!' dobefore do- SiteSetting.expects(:queue_jobs?).at_least_once.returns(false)+ Jobs.run_immediately!endit "doesn't enqueue in sidekiq" dodiff --git a/spec/jobs/pull_hotlinked_images_spec.rb b/spec/jobs/pull_hotlinked_images_spec.rbindex 2415696ff00..2450b7b9565 100644--- a/spec/jobs/pull_hotlinked_images_spec.rb+++ b/spec/jobs/pull_hotlinked_images_spec.rb@@ -32,7 +32,7 @@ describe Jobs::PullHotlinkedImages dodescribe '#execute' dobefore do- run_jobs_synchronously!+ Jobs.run_immediately!FastImage.expects(:size).returns([100, 100]).at_least_onceend@@ -72,7 +72,6 @@ describe Jobs::PullHotlinkedImages dolet(:api_url) { "https://en.wikipedia.org/w/api.php?action=query&titles=#{media}&prop=imageinfo&iilimit=50&iiprop=timestamp|user|url&iiurlwidth=500&format=json" }before do- SiteSetting.queue_jobs = truestub_request(:head, url)stub_request(:get, url).to_return(body: '')stub_request(:get, api_url).to_return(body: "{diff --git a/spec/lib/upload_recovery_spec.rb b/spec/lib/upload_recovery_spec.rbindex b9a6b911ee7..69d9412b8a6 100644--- a/spec/lib/upload_recovery_spec.rb+++ b/spec/lib/upload_recovery_spec.rb@@ -31,7 +31,7 @@ RSpec.describe UploadRecovery dobefore doSiteSetting.authorized_extensions = 'png|pdf'- run_jobs_synchronously!+ Jobs.run_immediately!endafter dodiff --git a/spec/models/category_user_spec.rb b/spec/models/category_user_spec.rbindex 048a19a2d09..f95d758f177 100644--- a/spec/models/category_user_spec.rb+++ b/spec/models/category_user_spec.rb@@ -68,7 +68,7 @@ describe CategoryUser docontext 'integration' dobefore do- run_jobs_synchronously!+ Jobs.run_immediately!NotificationEmailer.enableenddiff --git a/spec/models/discourse_single_sign_on_spec.rb b/spec/models/discourse_single_sign_on_spec.rbindex 95f71d0f417..4409b574112 100644--- a/spec/models/discourse_single_sign_on_spec.rb+++ b/spec/models/discourse_single_sign_on_spec.rb@@ -8,7 +8,7 @@ describe DiscourseSingleSignOn doSiteSetting.sso_url = @sso_urlSiteSetting.enable_sso = trueSiteSetting.sso_secret = @sso_secret- run_jobs_synchronously!+ Jobs.run_immediately!enddef make_ssodiff --git a/spec/models/post_action_spec.rb b/spec/models/post_action_spec.rbindex 37392835283..923ec3fd740 100644--- a/spec/models/post_action_spec.rb+++ b/spec/models/post_action_spec.rb@@ -1072,7 +1072,7 @@ describe PostAction doendit "should create a notification in the related topic" do- run_jobs_synchronously!+ Jobs.run_immediately!post = Fabricate(:post)user = Fabricate(:user)action = PostAction.act(user, post, PostActionType.types[:spam], message: "WAT")@@ -1089,7 +1089,7 @@ describe PostAction doendit "should not add a moderator post when post is flagged via private message" do- run_jobs_synchronously!+ Jobs.run_immediately!post = Fabricate(:post)user = Fabricate(:user)action = PostAction.act(user, post, PostActionType.types[:notify_user], message: "WAT")diff --git a/spec/models/post_mover_spec.rb b/spec/models/post_mover_spec.rbindex 4e117d9dc84..82dc48dc034 100644--- a/spec/models/post_mover_spec.rb+++ b/spec/models/post_mover_spec.rb@@ -41,7 +41,7 @@ describe PostMover dobefore doSiteSetting.tagging_enabled = true- run_jobs_synchronously!+ Jobs.run_immediately!p1.replies << p3p2.replies << p4UserActionCreator.enable@@ -570,7 +570,7 @@ describe PostMover dobefore doSiteSetting.tagging_enabled = true- run_jobs_synchronously!+ Jobs.run_immediately!p1.replies << p3p2.replies << p4UserActionCreator.enablediff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rbindex fe827d16b89..2f18227d199 100644--- a/spec/models/post_spec.rb+++ b/spec/models/post_spec.rb@@ -995,7 +995,7 @@ describe Post doendbefore do- run_jobs_synchronously!+ Jobs.run_immediately!enddescribe 'when user can not mention a group' dodiff --git a/spec/models/quoted_post_spec.rb b/spec/models/quoted_post_spec.rbindex 538a3f21ca4..593fe6f5f7b 100644--- a/spec/models/quoted_post_spec.rb+++ b/spec/models/quoted_post_spec.rb@@ -2,7 +2,7 @@ require 'rails_helper'describe QuotedPost doit 'correctly extracts quotes' do- run_jobs_synchronously!+ Jobs.run_immediately!topic = Fabricate(:topic)post1 = create_post(topic: topic, post_number: 1, raw: "foo bar")@@ -34,7 +34,7 @@ describe QuotedPost doendit "doesn't count quotes from the same post" do- run_jobs_synchronously!+ Jobs.run_immediately!topic = Fabricate(:topic)post = create_post(topic: topic, post_number: 1, raw: "foo bar")diff --git a/spec/models/tag_user_spec.rb b/spec/models/tag_user_spec.rbindex a57373ddbc9..dc1141692c0 100644--- a/spec/models/tag_user_spec.rb+++ b/spec/models/tag_user_spec.rb@@ -75,7 +75,7 @@ describe TagUser docontext "with some tag notification settings" dobefore do- run_jobs_synchronously!+ Jobs.run_immediately!endlet :watched_post dodiff --git a/spec/models/topic_spec.rb b/spec/models/topic_spec.rbindex d0ecd98a432..c28ce6f0557 100644--- a/spec/models/topic_spec.rb+++ b/spec/models/topic_spec.rb@@ -1280,7 +1280,7 @@ describe Topic dodescribe 'user that is watching the new category' doit 'should generate the notification for the topic' do- run_jobs_synchronously!+ Jobs.run_immediately!topic.posts << Fabricate(:post)@@ -1602,7 +1602,7 @@ describe Topic dolet(:topic) { Fabricate(:topic, category: category) }it "should be able to override category's default auto close" do- run_jobs_synchronously!+ Jobs.run_immediately!expect(topic.topic_timers.first.duration).to eq(4)diff --git a/spec/models/topic_timer_spec.rb b/spec/models/topic_timer_spec.rbindex e49d51a3b00..cf7f7826151 100644--- a/spec/models/topic_timer_spec.rb+++ b/spec/models/topic_timer_spec.rb@@ -190,7 +190,7 @@ RSpec.describe TopicTimer, type: :model doendbefore do- run_jobs_synchronously!+ Jobs.run_immediately!endit 'should close the topic' do@@ -219,7 +219,7 @@ RSpec.describe TopicTimer, type: :model doendbefore do- run_jobs_synchronously!+ Jobs.run_immediately!endit 'should open the topic' dodiff --git a/spec/models/topic_user_spec.rb b/spec/models/topic_user_spec.rbindex ebe3e561f8d..be49ab45399 100644--- a/spec/models/topic_user_spec.rb+++ b/spec/models/topic_user_spec.rb@@ -451,7 +451,7 @@ describe TopicUser doit "will receive email notification for every topic" douser1 = Fabricate(:user)- run_jobs_synchronously!+ Jobs.run_immediately!SiteSetting.default_email_mailing_list_mode = trueSiteSetting.default_email_mailing_list_mode_frequency = 1diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rbindex dfce0b76ef1..5e5f0617014 100644--- a/spec/models/user_spec.rb+++ b/spec/models/user_spec.rb@@ -1088,7 +1088,7 @@ describe User docontext "with a reply" dobefore do- run_jobs_synchronously!+ Jobs.run_immediately!PostCreator.new(Fabricate(:user),raw: 'whatever this is a raw post',topic_id: topic.id,diff --git a/spec/rails_helper.rb b/spec/rails_helper.rbindex cc0f80b7925..6eaa2a2934a 100644--- a/spec/rails_helper.rb+++ b/spec/rails_helper.rb@@ -176,6 +176,11 @@ RSpec.configure do |config|$test_cleanup_callbacks.reverse_each(&:call)$test_cleanup_callbacks = nilend++ # Running jobs are expensive and most of our tests are not concern with+ # code that runs inside jobs. run_later! means they are put on the redis+ # queue and never processed.+ Jobs.run_later!endconfig.before(:each, type: :multisite) dodiff --git a/spec/requests/admin/flags_controller_spec.rb b/spec/requests/admin/flags_controller_spec.rbindex cba8d017e66..c509e097a00 100644--- a/spec/requests/admin/flags_controller_spec.rb+++ b/spec/requests/admin/flags_controller_spec.rb@@ -37,7 +37,7 @@ RSpec.describe Admin::FlagsController docontext '#agree' doit 'should raise a reasonable error if a flag was deferred and then someone else agreed' do- run_jobs_synchronously!+ Jobs.run_immediately!_post_action = PostAction.act(user, post_1, PostActionType.types[:spam], message: 'bad')@@ -52,7 +52,7 @@ RSpec.describe Admin::FlagsController doendit 'should be able to agree and keep content' do- run_jobs_synchronously!+ Jobs.run_immediately!post_action = PostAction.act(user, post_1, PostActionType.types[:spam], message: 'bad')@@ -69,7 +69,7 @@ RSpec.describe Admin::FlagsController doit 'should be able to hide spam' doSiteSetting.allow_user_locale = true- run_jobs_synchronously!+ Jobs.run_immediately!post_action = PostAction.act(user, post_1, PostActionType.types[:spam], message: 'bad')admin.update!(locale: 'ja')@@ -90,7 +90,7 @@ RSpec.describe Admin::FlagsController doendit 'should not delete category topic' do- run_jobs_synchronously!+ Jobs.run_immediately!category.update_column(:topic_id, first_post.topic_id)PostAction.act(user, first_post, PostActionType.types[:spam], message: 'bad')diff --git a/spec/requests/admin/groups_controller_spec.rb b/spec/requests/admin/groups_controller_spec.rbindex 326a3012905..955bf78592d 100644--- a/spec/requests/admin/groups_controller_spec.rb+++ b/spec/requests/admin/groups_controller_spec.rb@@ -78,7 +78,7 @@ RSpec.describe Admin::GroupsController dolet(:user2) { Fabricate(:user, trust_level: 4) }it "can assign users to a group by email or username" do- run_jobs_synchronously!+ Jobs.run_immediately!put "/admin/groups/bulk.json", params: {group_id: group.id, users: [user.username.upcase, user2.email, 'doesnt_exist']diff --git a/spec/requests/categories_controller_spec.rb b/spec/requests/categories_controller_spec.rbindex 92f0a6dc534..e8568963cef 100644--- a/spec/requests/categories_controller_spec.rb+++ b/spec/requests/categories_controller_spec.rb@@ -78,7 +78,7 @@ describe CategoriesController dodescribe "logged in" dobefore do- run_jobs_synchronously!+ Jobs.run_immediately!sign_in(admin)end@@ -226,7 +226,7 @@ describe CategoriesController docontext '#update' dobefore do- run_jobs_synchronously!+ Jobs.run_immediately!endit "requires the user to be logged in" dodiff --git a/spec/requests/embed_controller_spec.rb b/spec/requests/embed_controller_spec.rbindex 6c79ab98403..cd4a2dfa9ea 100644--- a/spec/requests/embed_controller_spec.rb+++ b/spec/requests/embed_controller_spec.rb@@ -74,7 +74,7 @@ describe EmbedController dolet(:headers) { { 'REFERER' => embed_url } }before do- run_jobs_synchronously!+ Jobs.run_immediately!endit "raises an error with no referer" dodiff --git a/spec/requests/invites_controller_spec.rb b/spec/requests/invites_controller_spec.rbindex 9da47143384..2737d109730 100644--- a/spec/requests/invites_controller_spec.rb+++ b/spec/requests/invites_controller_spec.rb@@ -298,10 +298,6 @@ describe InvitesController doendcontext '.post_process_invite' do- before do- SiteSetting.queue_jobs = true- end-it 'sends a welcome message if set' douser.send_welcome_message = trueput "/invites/show/#{invite.invite_key}.json"@@ -466,7 +462,6 @@ describe InvitesController doendit "resends the invite" do- SiteSetting.queue_jobs = truepost "/invites/reinvite.json", params: { email: invite.email }expect(response.status).to eq(200)expect(Jobs::InviteEmail.jobs.size).to eq(1)@@ -496,7 +491,6 @@ describe InvitesController doendit "allows admin to bulk invite" do- SiteSetting.queue_jobs = truesign_in(Fabricate(:admin))post "/invites/upload_csv.json", params: { file: file, name: filename }expect(response.status).to eq(200)diff --git a/spec/requests/posts_controller_spec.rb b/spec/requests/posts_controller_spec.rbindex 20a58b3a868..89cf1fdbe8d 100644--- a/spec/requests/posts_controller_spec.rb+++ b/spec/requests/posts_controller_spec.rb@@ -730,7 +730,7 @@ describe PostsController doendit 'allows to create posts in import_mode' do- run_jobs_synchronously!+ Jobs.run_immediately!NotificationEmailer.enablepost_1 = Fabricate(:post)user = Fabricate(:user)diff --git a/spec/services/group_mentions_updater_spec.rb b/spec/services/group_mentions_updater_spec.rbindex 0491dbdbe84..eb47170ab10 100644--- a/spec/services/group_mentions_updater_spec.rb+++ b/spec/services/group_mentions_updater_spec.rb@@ -4,7 +4,7 @@ RSpec.describe GroupMentionsUpdater dolet(:post) { Fabricate(:post) }before do- run_jobs_synchronously!+ Jobs.run_immediately!enddescribe '.update' dodiff --git a/spec/services/post_alerter_spec.rb b/spec/services/post_alerter_spec.rbindex 7108917c698..9143b9e4746 100644--- a/spec/services/post_alerter_spec.rb+++ b/spec/services/post_alerter_spec.rb@@ -213,7 +213,7 @@ describe PostAlerter dolet(:linking_post) { create_post(raw: "my magic topic\n##{Discourse.base_url}#{post1.url}") }before do- run_jobs_synchronously!+ Jobs.run_immediately!endit "will notify correctly on linking" do@@ -289,7 +289,7 @@ describe PostAlerter dolet(:topic) { mention_post.topic }before do- run_jobs_synchronously!+ Jobs.run_immediately!endit 'notifies a user' do@@ -591,7 +591,7 @@ describe PostAlerter doendit "correctly pushes notifications if configured correctly" do- run_jobs_synchronously!+ Jobs.run_immediately!SiteSetting.allowed_user_api_push_urls = "https://site.com/push|https://site2.com/push"2.times do |i|@@ -935,7 +935,7 @@ describe PostAlerter dobefore doSiteSetting.tagging_enabled = true- SiteSetting.queue_jobs = false+ Jobs.run_immediately!endit "triggers a notification" dodiff --git a/spec/services/user_anonymizer_spec.rb b/spec/services/user_anonymizer_spec.rbindex 8e3048b953d..70f75ce8a66 100644--- a/spec/services/user_anonymizer_spec.rb+++ b/spec/services/user_anonymizer_spec.rb@@ -136,7 +136,7 @@ describe UserAnonymizer doendit "updates the avatar in posts" do- run_jobs_synchronously!+ Jobs.run_immediately!upload = Fabricate(:upload, user: user)user.user_avatar = UserAvatar.new(user_id: user.id, custom_upload_id: upload.id)user.uploaded_avatar_id = upload.id # chosen in user preferences@@ -214,7 +214,7 @@ describe UserAnonymizer docontext "executes job" dobefore do- run_jobs_synchronously!+ Jobs.run_immediately!endit "removes invites" do@@ -302,7 +302,7 @@ describe UserAnonymizer doendit "exhaustively replaces all user ips" do- run_jobs_synchronously!+ Jobs.run_immediately!link = IncomingLink.create!(current_user_id: user.id, ip_address: old_ip, post_id: post.id)screened_email = ScreenedEmail.create!(email: user.email, ip_address: old_ip)diff --git a/spec/services/username_changer_spec.rb b/spec/services/username_changer_spec.rbindex 8ae83f191dc..9c45d9a3f0d 100644--- a/spec/services/username_changer_spec.rb+++ b/spec/services/username_changer_spec.rb@@ -2,7 +2,7 @@ require 'rails_helper'describe UsernameChanger dobefore do- run_jobs_synchronously!+ Jobs.run_immediately!enddescribe '#change' dodiff --git a/spec/support/helpers.rb b/spec/support/helpers.rbindex 9d709d3e1dd..455230e1b48 100644--- a/spec/support/helpers.rb+++ b/spec/support/helpers.rb@@ -5,12 +5,6 @@ module Helpers@next_seq = (@next_seq || 0) + 1end- # If you don't `queue_jobs` it means you want to run them synchronously. This method- # makes that more clear in tests. It is automatically reset after every test.- def run_jobs_synchronously!- SiteSetting.queue_jobs = false- end-def log_in(fabricator = nil)user = Fabricate(fabricator || :user)log_in_user(user)