2014-05-18 10:24:30 -04:00
|
|
|
require 'helper'
|
|
|
|
require 'jobs/hello_job'
|
2014-08-12 06:53:46 -04:00
|
|
|
require 'jobs/logging_job'
|
|
|
|
require 'jobs/nested_job'
|
2014-05-18 10:24:30 -04:00
|
|
|
|
|
|
|
class QueueNamingTest < ActiveSupport::TestCase
|
|
|
|
test 'name derived from base' do
|
2014-08-15 16:32:08 -04:00
|
|
|
assert_equal "default", HelloJob.queue_name
|
2014-05-18 10:24:30 -04:00
|
|
|
end
|
2014-08-12 06:53:46 -04:00
|
|
|
|
2014-05-18 10:24:30 -04:00
|
|
|
test 'name appended in job' do
|
|
|
|
begin
|
|
|
|
HelloJob.queue_as :greetings
|
2014-06-09 12:49:14 -04:00
|
|
|
LoggingJob.queue_as :bookkeeping
|
|
|
|
|
2014-08-15 16:32:08 -04:00
|
|
|
assert_equal "default", NestedJob.queue_name
|
|
|
|
assert_equal "greetings", HelloJob.queue_name
|
|
|
|
assert_equal "bookkeeping", LoggingJob.queue_name
|
2014-05-18 10:24:30 -04:00
|
|
|
ensure
|
2014-08-15 16:32:08 -04:00
|
|
|
HelloJob.queue_name = LoggingJob.queue_name = ActiveJob::Base.default_queue_name
|
2014-05-18 10:24:30 -04:00
|
|
|
end
|
|
|
|
end
|
2014-08-18 04:17:36 -04:00
|
|
|
|
|
|
|
test 'should prefix the queue name' do
|
|
|
|
begin
|
|
|
|
original_queue_name_prefix = ActiveJob::Base.queue_name_prefix
|
|
|
|
original_queue_name = HelloJob.queue_name
|
|
|
|
|
|
|
|
ActiveJob::Base.queue_name_prefix = 'aj'
|
|
|
|
HelloJob.queue_as :low
|
|
|
|
assert_equal 'aj_low', HelloJob.queue_name
|
|
|
|
ensure
|
|
|
|
ActiveJob::Base.queue_name_prefix = original_queue_name_prefix
|
|
|
|
HelloJob.queue_name = original_queue_name
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-05-18 10:24:30 -04:00
|
|
|
end
|