mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Have .queue_as only set queue name for job in question.
This commit is contained in:
parent
694b562080
commit
da6a86f875
3 changed files with 18 additions and 6 deletions
|
@ -9,8 +9,8 @@ require 'active_job/logging'
|
|||
module ActiveJob
|
||||
class Base
|
||||
extend QueueAdapter
|
||||
extend QueueName
|
||||
|
||||
include QueueName
|
||||
include Enqueuing
|
||||
include Execution
|
||||
include Callbacks
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue