From b555684bbd441b1e28d7c74ca142391dc8633e5a Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Mon, 30 Aug 2010 15:23:41 -0300 Subject: [PATCH] Move duplicated code into a method on its own --- test/functional/invite_controller_test.rb | 18 +++++++++--------- test/test_helper.rb | 6 ++++++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/test/functional/invite_controller_test.rb b/test/functional/invite_controller_test.rb index 0077478..cd9225d 100644 --- a/test/functional/invite_controller_test.rb +++ b/test/functional/invite_controller_test.rb @@ -18,7 +18,7 @@ class InviteControllerTest < ActionController::TestCase end assert_difference InviteFriend, :count, 1 do - Delayed::Worker.new.work_off + process_delayed_job_queue end end @@ -30,7 +30,7 @@ class InviteControllerTest < ActionController::TestCase end assert_difference InviteFriend, :count, 1 do - Delayed::Worker.new.work_off + process_delayed_job_queue end end @@ -42,7 +42,7 @@ class InviteControllerTest < ActionController::TestCase end assert_difference InviteFriend, :count, 1 do - Delayed::Worker.new.work_off + process_delayed_job_queue end end @@ -54,7 +54,7 @@ class InviteControllerTest < ActionController::TestCase end assert_difference InviteFriend, :count, 2 do - Delayed::Worker.new.work_off + process_delayed_job_queue end end @@ -66,7 +66,7 @@ class InviteControllerTest < ActionController::TestCase end assert_difference InviteFriend, :count, 1 do - Delayed::Worker.new.work_off + process_delayed_job_queue end end @@ -78,7 +78,7 @@ class InviteControllerTest < ActionController::TestCase end assert_no_difference InviteFriend, :count do - Delayed::Worker.new.work_off + process_delayed_job_queue end end @@ -93,7 +93,7 @@ class InviteControllerTest < ActionController::TestCase end assert_no_difference InviteFriend, :count do - Delayed::Worker.new.work_off + process_delayed_job_queue end end @@ -164,7 +164,7 @@ class InviteControllerTest < ActionController::TestCase post :select_friends, :profile => profile.identifier, :manual_import_addresses => "#{friend.name} <#{friend.email}>", :import_from => "manual", :mail_template => "click: ", :contact_list => contact_list.id assert ContactList.exists?(contact_list.id) - Delayed::Worker.new.work_off + process_delayed_job_queue assert !ContactList.exists?(contact_list.id) end @@ -173,7 +173,7 @@ class InviteControllerTest < ActionController::TestCase post :select_friends, :profile => profile.identifier, :manual_import_addresses => "#{friend.name} <#{friend.email}>", :import_from => "not_manual", :mail_template => "click: ", :contact_list => contact_list.id assert ContactList.exists?(contact_list.id) - Delayed::Worker.new.work_off + process_delayed_job_queue assert !ContactList.exists?(contact_list.id) end diff --git a/test/test_helper.rb b/test/test_helper.rb index 4760258..359eb86 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -175,6 +175,12 @@ class Test::Unit::TestCase @request.instance_variable_set('@host', name) end + def process_delayed_job_queue + silence_stream(STDOUT) do + Delayed::Worker.new.work_off + end + end + end module NoosferoTestHelper -- libgit2 0.21.2