diff options
author | Blake Gentry <blakesgentry@gmail.com> | 2014-10-09 10:33:55 -0700 |
---|---|---|
committer | Blake Gentry <blakesgentry@gmail.com> | 2014-10-09 19:42:43 -0700 |
commit | 4a1dbba108ece1a957b26d1e6280c1a8cd986fe8 (patch) | |
tree | 624b7980b9575488f53a2dfcb8b09f5b8acc2c3c | |
parent | e3207bdbba55f3806441f22b175557579bc0b051 (diff) | |
download | rails-4a1dbba108ece1a957b26d1e6280c1a8cd986fe8.tar.gz rails-4a1dbba108ece1a957b26d1e6280c1a8cd986fe8.tar.bz2 rails-4a1dbba108ece1a957b26d1e6280c1a8cd986fe8.zip |
ActiveJob: allow blank queue names
As discussed in #17195, Que uses blank queue names by default for
performance reasons. At the very least, ActiveJob should allow users to
choose "" as their queue name. This commit allows blank queue names, as
well as tests to make sure that nil queue names still use the default.
-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 |