提交 64e64c6f 编写于 作者: Y Yves Senn

tests, move `original_` var assignments outside of `begin`.

上级 5f1a274b
......@@ -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
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册