Commit b555684bbd441b1e28d7c74ca142391dc8633e5a
1 parent
6120369e
Exists in
master
and in
28 other branches
Move duplicated code into a method on its own
(ActionItem1640)
Showing
2 changed files
with
15 additions
and
9 deletions
Show diff stats
test/functional/invite_controller_test.rb
| @@ -18,7 +18,7 @@ class InviteControllerTest < ActionController::TestCase | @@ -18,7 +18,7 @@ class InviteControllerTest < ActionController::TestCase | ||
| 18 | end | 18 | end |
| 19 | 19 | ||
| 20 | assert_difference InviteFriend, :count, 1 do | 20 | assert_difference InviteFriend, :count, 1 do |
| 21 | - Delayed::Worker.new.work_off | 21 | + process_delayed_job_queue |
| 22 | end | 22 | end |
| 23 | end | 23 | end |
| 24 | 24 | ||
| @@ -30,7 +30,7 @@ class InviteControllerTest < ActionController::TestCase | @@ -30,7 +30,7 @@ class InviteControllerTest < ActionController::TestCase | ||
| 30 | end | 30 | end |
| 31 | 31 | ||
| 32 | assert_difference InviteFriend, :count, 1 do | 32 | assert_difference InviteFriend, :count, 1 do |
| 33 | - Delayed::Worker.new.work_off | 33 | + process_delayed_job_queue |
| 34 | end | 34 | end |
| 35 | end | 35 | end |
| 36 | 36 | ||
| @@ -42,7 +42,7 @@ class InviteControllerTest < ActionController::TestCase | @@ -42,7 +42,7 @@ class InviteControllerTest < ActionController::TestCase | ||
| 42 | end | 42 | end |
| 43 | 43 | ||
| 44 | assert_difference InviteFriend, :count, 1 do | 44 | assert_difference InviteFriend, :count, 1 do |
| 45 | - Delayed::Worker.new.work_off | 45 | + process_delayed_job_queue |
| 46 | end | 46 | end |
| 47 | end | 47 | end |
| 48 | 48 | ||
| @@ -54,7 +54,7 @@ class InviteControllerTest < ActionController::TestCase | @@ -54,7 +54,7 @@ class InviteControllerTest < ActionController::TestCase | ||
| 54 | end | 54 | end |
| 55 | 55 | ||
| 56 | assert_difference InviteFriend, :count, 2 do | 56 | assert_difference InviteFriend, :count, 2 do |
| 57 | - Delayed::Worker.new.work_off | 57 | + process_delayed_job_queue |
| 58 | end | 58 | end |
| 59 | end | 59 | end |
| 60 | 60 | ||
| @@ -66,7 +66,7 @@ class InviteControllerTest < ActionController::TestCase | @@ -66,7 +66,7 @@ class InviteControllerTest < ActionController::TestCase | ||
| 66 | end | 66 | end |
| 67 | 67 | ||
| 68 | assert_difference InviteFriend, :count, 1 do | 68 | assert_difference InviteFriend, :count, 1 do |
| 69 | - Delayed::Worker.new.work_off | 69 | + process_delayed_job_queue |
| 70 | end | 70 | end |
| 71 | end | 71 | end |
| 72 | 72 | ||
| @@ -78,7 +78,7 @@ class InviteControllerTest < ActionController::TestCase | @@ -78,7 +78,7 @@ class InviteControllerTest < ActionController::TestCase | ||
| 78 | end | 78 | end |
| 79 | 79 | ||
| 80 | assert_no_difference InviteFriend, :count do | 80 | assert_no_difference InviteFriend, :count do |
| 81 | - Delayed::Worker.new.work_off | 81 | + process_delayed_job_queue |
| 82 | end | 82 | end |
| 83 | end | 83 | end |
| 84 | 84 | ||
| @@ -93,7 +93,7 @@ class InviteControllerTest < ActionController::TestCase | @@ -93,7 +93,7 @@ class InviteControllerTest < ActionController::TestCase | ||
| 93 | end | 93 | end |
| 94 | 94 | ||
| 95 | assert_no_difference InviteFriend, :count do | 95 | assert_no_difference InviteFriend, :count do |
| 96 | - Delayed::Worker.new.work_off | 96 | + process_delayed_job_queue |
| 97 | end | 97 | end |
| 98 | end | 98 | end |
| 99 | 99 | ||
| @@ -164,7 +164,7 @@ class InviteControllerTest < ActionController::TestCase | @@ -164,7 +164,7 @@ class InviteControllerTest < ActionController::TestCase | ||
| 164 | post :select_friends, :profile => profile.identifier, :manual_import_addresses => "#{friend.name} <#{friend.email}>", :import_from => "manual", :mail_template => "click: <url>", :contact_list => contact_list.id | 164 | post :select_friends, :profile => profile.identifier, :manual_import_addresses => "#{friend.name} <#{friend.email}>", :import_from => "manual", :mail_template => "click: <url>", :contact_list => contact_list.id |
| 165 | 165 | ||
| 166 | assert ContactList.exists?(contact_list.id) | 166 | assert ContactList.exists?(contact_list.id) |
| 167 | - Delayed::Worker.new.work_off | 167 | + process_delayed_job_queue |
| 168 | assert !ContactList.exists?(contact_list.id) | 168 | assert !ContactList.exists?(contact_list.id) |
| 169 | end | 169 | end |
| 170 | 170 | ||
| @@ -173,7 +173,7 @@ class InviteControllerTest < ActionController::TestCase | @@ -173,7 +173,7 @@ class InviteControllerTest < ActionController::TestCase | ||
| 173 | post :select_friends, :profile => profile.identifier, :manual_import_addresses => "#{friend.name} <#{friend.email}>", :import_from => "not_manual", :mail_template => "click: <url>", :contact_list => contact_list.id | 173 | post :select_friends, :profile => profile.identifier, :manual_import_addresses => "#{friend.name} <#{friend.email}>", :import_from => "not_manual", :mail_template => "click: <url>", :contact_list => contact_list.id |
| 174 | 174 | ||
| 175 | assert ContactList.exists?(contact_list.id) | 175 | assert ContactList.exists?(contact_list.id) |
| 176 | - Delayed::Worker.new.work_off | 176 | + process_delayed_job_queue |
| 177 | assert !ContactList.exists?(contact_list.id) | 177 | assert !ContactList.exists?(contact_list.id) |
| 178 | end | 178 | end |
| 179 | 179 |
test/test_helper.rb
| @@ -175,6 +175,12 @@ class Test::Unit::TestCase | @@ -175,6 +175,12 @@ class Test::Unit::TestCase | ||
| 175 | @request.instance_variable_set('@host', name) | 175 | @request.instance_variable_set('@host', name) |
| 176 | end | 176 | end |
| 177 | 177 | ||
| 178 | + def process_delayed_job_queue | ||
| 179 | + silence_stream(STDOUT) do | ||
| 180 | + Delayed::Worker.new.work_off | ||
| 181 | + end | ||
| 182 | + end | ||
| 183 | + | ||
| 178 | end | 184 | end |
| 179 | 185 | ||
| 180 | module NoosferoTestHelper | 186 | module NoosferoTestHelper |