1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

tests, move original_ var assignments outside of begin.

This commit is contained in:
Yves Senn 2014-10-10 08:53:22 +02:00
parent 5f1a274b68
commit 64e64c6f04
2 changed files with 16 additions and 11 deletions

View file

@ -9,8 +9,9 @@ class QueueNamingTest < ActiveSupport::TestCase
end
test 'uses given queue name job' do
original_queue_name = HelloJob.queue_name
begin
original_queue_name = HelloJob.queue_name
HelloJob.queue_as :greetings
assert_equal "greetings", HelloJob.new.queue_name
ensure
@ -19,8 +20,9 @@ class QueueNamingTest < ActiveSupport::TestCase
end
test 'allows a blank queue name' do
original_queue_name = HelloJob.queue_name
begin
original_queue_name = HelloJob.queue_name
HelloJob.queue_as ""
assert_equal "", HelloJob.new.queue_name
ensure
@ -29,8 +31,9 @@ class QueueNamingTest < ActiveSupport::TestCase
end
test 'does not use a nil queue name' do
original_queue_name = HelloJob.queue_name
begin
original_queue_name = HelloJob.queue_name
HelloJob.queue_as nil
assert_equal "default", HelloJob.new.queue_name
ensure
@ -39,8 +42,9 @@ class QueueNamingTest < ActiveSupport::TestCase
end
test 'evals block given to queue_as to determine queue' do
original_queue_name = HelloJob.queue_name
begin
original_queue_name = HelloJob.queue_name
HelloJob.queue_as { :another }
assert_equal "another", HelloJob.new.queue_name
ensure
@ -49,8 +53,9 @@ class QueueNamingTest < ActiveSupport::TestCase
end
test 'can use arguments to determine queue_name in queue_as block' do
original_queue_name = HelloJob.queue_name
begin
original_queue_name = HelloJob.queue_name
HelloJob.queue_as { self.arguments.first=='1' ? :one : :two }
assert_equal "one", HelloJob.new('1').queue_name
assert_equal "two", HelloJob.new('3').queue_name
@ -60,10 +65,10 @@ class QueueNamingTest < ActiveSupport::TestCase
end
test 'queu_name_prefix prepended to the queue name' do
begin
original_queue_name_prefix = ActiveJob::Base.queue_name_prefix
original_queue_name = HelloJob.queue_name
original_queue_name_prefix = ActiveJob::Base.queue_name_prefix
original_queue_name = HelloJob.queue_name
begin
ActiveJob::Base.queue_name_prefix = 'aj'
HelloJob.queue_as :low
assert_equal 'aj_low', HelloJob.queue_name
@ -77,5 +82,4 @@ class QueueNamingTest < ActiveSupport::TestCase
job = HelloJob.set(queue: :some_queue).perform_later
assert_equal "some_queue", job.queue_name
end
end

View file

@ -10,9 +10,10 @@ class QueuingTest < ActiveSupport::TestCase
end
test 'should not run jobs queued on a non-listenting queue' do
skip if adapter_is?(:inline) || adapter_is?(:sucker_punch)
old_queue = TestJob.queue_name
begin
skip if adapter_is?(:inline) || adapter_is?(:sucker_punch)
old_queue = TestJob.queue_name
TestJob.queue_as :some_other_queue
TestJob.perform_later @id
wait_for_jobs_to_finish_for(2.seconds)