diff options
-rw-r--r-- | activejob/lib/active_job/queue_name.rb | 2 | ||||
-rw-r--r-- | activejob/test/cases/queue_naming_test.rb | 20 |
2 files changed, 21 insertions, 1 deletions
diff --git a/activejob/lib/active_job/queue_name.rb b/activejob/lib/active_job/queue_name.rb index d6ac01a921..d167617e4e 100644 --- a/activejob/lib/active_job/queue_name.rb +++ b/activejob/lib/active_job/queue_name.rb @@ -24,7 +24,7 @@ module ActiveJob end def queue_name_from_part(part_name) #:nodoc: - queue_name = part_name.to_s.presence || default_queue_name + queue_name = part_name || default_queue_name name_parts = [queue_name_prefix.presence, queue_name] name_parts.compact.join('_') end diff --git a/activejob/test/cases/queue_naming_test.rb b/activejob/test/cases/queue_naming_test.rb index 4052477543..6658cf954c 100644 --- a/activejob/test/cases/queue_naming_test.rb +++ b/activejob/test/cases/queue_naming_test.rb @@ -18,6 +18,26 @@ class QueueNamingTest < ActiveSupport::TestCase end end + test 'allows a blank queue name' do + begin + original_queue_name = HelloJob.queue_name + HelloJob.queue_as "" + assert_equal "", HelloJob.new.queue_name + ensure + HelloJob.queue_name = original_queue_name + end + end + + test 'does not use a nil queue name' do + begin + original_queue_name = HelloJob.queue_name + HelloJob.queue_as nil + assert_equal "default", HelloJob.new.queue_name + ensure + HelloJob.queue_name = original_queue_name + end + end + test 'evals block given to queue_as to determine queue' do begin original_queue_name = HelloJob.queue_name |