diff --git a/lib/active_scheduler/resque_wrapper.rb b/lib/active_scheduler/resque_wrapper.rb index 5a3373e..9a9d0b3 100644 --- a/lib/active_scheduler/resque_wrapper.rb +++ b/lib/active_scheduler/resque_wrapper.rb @@ -23,7 +23,7 @@ def self.wrap(schedule) class: 'ActiveScheduler::ResqueWrapper', queue: queue, args: [{ - job_class: opts[:class], + job_class: opts[:class] || job, queue_name: queue, arguments: opts[:arguments] }] diff --git a/spec/active_scheduler/resque_wrapper_spec.rb b/spec/active_scheduler/resque_wrapper_spec.rb index 767faa1..99db5a8 100644 --- a/spec/active_scheduler/resque_wrapper_spec.rb +++ b/spec/active_scheduler/resque_wrapper_spec.rb @@ -66,6 +66,25 @@ expect(wrapped['no_queue_job']['queue']).to eq 'default' end end + + context "when the schedule name is the class name" do + let(:schedule) { YAML.load_file 'spec/fixtures/schedule_name_is_class_name.yaml' } + + it "queues up a job, using the schedule name for the class name" do + expect(wrapped['MyScheduleNameIsClassNameJob']).to eq( + "class" => "ActiveScheduler::ResqueWrapper", + "queue" => "myscheduledjobqueue", + "description" => "It's a self-named job.", + "cron" => "* * * * *", + "args" => [{ + "job_class" => "MyScheduleNameIsClassNameJob", + "queue_name" => "myscheduledjobqueue", + "arguments" => nil + }] + ) + end + + end end describe ".perform" do diff --git a/spec/fixtures/schedule_name_is_class_name.yaml b/spec/fixtures/schedule_name_is_class_name.yaml new file mode 100644 index 0000000..eb1ef91 --- /dev/null +++ b/spec/fixtures/schedule_name_is_class_name.yaml @@ -0,0 +1,6 @@ +MyScheduleNameIsClassNameJob: + cron: "* * * * *" + queue: "myscheduledjobqueue" + args: + - + description: "It's a self-named job."