diff --git a/lib/active_scheduler/resque_wrapper.rb b/lib/active_scheduler/resque_wrapper.rb index 60ec63f..c606020 100644 --- a/lib/active_scheduler/resque_wrapper.rb +++ b/lib/active_scheduler/resque_wrapper.rb @@ -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 diff --git a/spec/active_scheduler/resque_wrapper_spec.rb b/spec/active_scheduler/resque_wrapper_spec.rb index 754eab8..e0747dd 100644 --- a/spec/active_scheduler/resque_wrapper_spec.rb +++ b/spec/active_scheduler/resque_wrapper_spec.rb @@ -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