Skip to content

Commit

Permalink
Merge branch 'use_default_queue_from_job'
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinAiken committed Dec 15, 2016
2 parents c366676 + 4683fb7 commit 64eb2ab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 4 additions & 2 deletions lib/active_scheduler/resque_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ def self.wrap(schedule)
schedule.each do |job, opts|
class_name = opts[:class] || job
next if class_name =~ /ActiveScheduler::ResqueWrapper/
next unless class_name.constantize <= ActiveJob::Base

klass = class_name.constantize
next unless klass <= ActiveJob::Base

queue = opts[:queue] || 'default'
queue = opts[:queue] || klass.queue_name
args = opts[:args]
named_args = opts[:named_args] || false

Expand Down
11 changes: 8 additions & 3 deletions spec/active_scheduler/resque_wrapper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,14 @@
context "when the queue is blank" do
let(:schedule) { YAML.load_file 'spec/fixtures/no_queue.yaml' }

it "uses 'default'" do
stub_jobs("SimpleJob")
expect(wrapped['no_queue_job']['queue']).to eq 'default'
it "uses the job's queue" do
simple_job = Class.new(ActiveJob::Base) do
queue_as :myscheduledjobqueue
end

stub_const("SimpleJob", simple_job)

expect(wrapped['no_queue_job']['queue']).to eq 'myscheduledjobqueue'
end
end

Expand Down

0 comments on commit 64eb2ab

Please sign in to comment.