aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/active_job/base.rb2
-rw-r--r--lib/active_job/queue_name.rb16
-rw-r--r--test/cases/queue_naming_test.rb6
3 files changed, 18 insertions, 6 deletions
diff --git a/lib/active_job/base.rb b/lib/active_job/base.rb
index 0c772e3126..d5ba253016 100644
--- a/lib/active_job/base.rb
+++ b/lib/active_job/base.rb
@@ -9,8 +9,8 @@ require 'active_job/logging'
module ActiveJob
class Base
extend QueueAdapter
- extend QueueName
+ include QueueName
include Enqueuing
include Execution
include Callbacks
diff --git a/lib/active_job/queue_name.rb b/lib/active_job/queue_name.rb
index a606b67370..859ddad034 100644
--- a/lib/active_job/queue_name.rb
+++ b/lib/active_job/queue_name.rb
@@ -1,10 +1,18 @@
module ActiveJob
module QueueName
- mattr_accessor(:queue_base_name) { "active_jobs" }
- mattr_accessor(:queue_name) { queue_base_name }
+ extend ActiveSupport::Concern
- def queue_as(part_name)
- self.queue_name = "#{queue_base_name}_#{part_name}"
+ module ClassMethods
+ mattr_accessor(:queue_base_name) { "active_jobs" }
+
+ def queue_as(part_name)
+ self.queue_name = "#{queue_base_name}_#{part_name}"
+ end
+ end
+
+ included do
+ class_attribute :queue_name
+ self.queue_name = queue_base_name
end
end
end \ No newline at end of file
diff --git a/test/cases/queue_naming_test.rb b/test/cases/queue_naming_test.rb
index e171474686..852643b9f6 100644
--- a/test/cases/queue_naming_test.rb
+++ b/test/cases/queue_naming_test.rb
@@ -9,9 +9,13 @@ class QueueNamingTest < ActiveSupport::TestCase
test 'name appended in job' do
begin
HelloJob.queue_as :greetings
+ LoggingJob.queue_as :bookkeeping
+
+ assert_equal "active_jobs", NestedJob.queue_name
assert_equal "active_jobs_greetings", HelloJob.queue_name
+ assert_equal "active_jobs_bookkeeping", LoggingJob.queue_name
ensure
- HelloJob.queue_name = HelloJob.queue_base_name
+ HelloJob.queue_name = LoggingJob.queue_name = ActiveJob::Base.queue_base_name
end
end
end