Add new run_jobs_synchronously! helper for tests

Previously if you wanted to have jobs execute in test mode, you'd have
to do `SiteSetting.queue_jobs = false`, because the opposite of queue
is to execute.

I found this very confusing, so I created a test helper called
`run_jobs_synchronously!` which is much more clear about what it does.
This commit is contained in:
Robin Ward
2019-03-11 16:58:35 -04:00
parent 2ee02cb6c7
commit d1d9a4f128
33 changed files with 51 additions and 45 deletions

View File

@ -37,7 +37,7 @@ RSpec.describe Admin::FlagsController do
context '#agree' do
it 'should raise a reasonable error if a flag was deferred and then someone else agreed' do
SiteSetting.queue_jobs = false
run_jobs_synchronously!
_post_action = PostAction.act(user, post_1, PostActionType.types[:spam], message: 'bad')
@ -52,7 +52,7 @@ RSpec.describe Admin::FlagsController do
end
it 'should be able to agree and keep content' do
SiteSetting.queue_jobs = false
run_jobs_synchronously!
post_action = PostAction.act(user, post_1, PostActionType.types[:spam], message: 'bad')
@ -69,7 +69,7 @@ RSpec.describe Admin::FlagsController do
it 'should be able to hide spam' do
SiteSetting.allow_user_locale = true
SiteSetting.queue_jobs = false
run_jobs_synchronously!
post_action = PostAction.act(user, post_1, PostActionType.types[:spam], message: 'bad')
admin.update!(locale: 'ja')
@ -90,7 +90,7 @@ RSpec.describe Admin::FlagsController do
end
it 'should not delete category topic' do
SiteSetting.queue_jobs = false
run_jobs_synchronously!
category.update_column(:topic_id, first_post.topic_id)
PostAction.act(user, first_post, PostActionType.types[:spam], message: 'bad')

View File

@ -78,7 +78,7 @@ RSpec.describe Admin::GroupsController do
let(:user2) { Fabricate(:user, trust_level: 4) }
it "can assign users to a group by email or username" do
SiteSetting.queue_jobs = false
run_jobs_synchronously!
put "/admin/groups/bulk.json", params: {
group_id: group.id, users: [user.username.upcase, user2.email, 'doesnt_exist']