Skip to content

Commit

Permalink
Merge pull request #1 from jeremycrosbie/master
Browse files Browse the repository at this point in the history
Use schedule name as class name if unspecified
  • Loading branch information
JustinAiken committed Oct 7, 2015
2 parents cb11543 + e63b377 commit b48dd1f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/active_scheduler/resque_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}]
Expand Down
19 changes: 19 additions & 0 deletions spec/active_scheduler/resque_wrapper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions spec/fixtures/schedule_name_is_class_name.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
MyScheduleNameIsClassNameJob:
cron: "* * * * *"
queue: "myscheduledjobqueue"
args:
-
description: "It's a self-named job."

0 comments on commit b48dd1f

Please sign in to comment.