Skip to content

Commit

Permalink
Deprecate arguments key in schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
ximus committed Apr 6, 2016
1 parent d645120 commit d1c12f1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
10 changes: 9 additions & 1 deletion lib/active_scheduler/resque_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,22 @@ def self.wrap(schedule)
next unless class_name.constantize <= ActiveJob::Base

queue = opts[:queue] || 'default'
args = opts[:args]

if !args && opts.has_key?(:arguments)
warn 'active_scheduler: [DEPRECATION] using the `arguments` key in ' \
'your resque schedule will soon be deprecated. Please revert to ' \
'the resque standard `args` key.'
args = opts[:arguments]
end

schedule[job] = {
class: 'ActiveScheduler::ResqueWrapper',
queue: queue,
args: [{
job_class: class_name,
queue_name: queue,
arguments: opts[:arguments]
arguments: args
}]
}

Expand Down
8 changes: 4 additions & 4 deletions spec/active_scheduler/resque_wrapper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"args" => [{
"job_class" => "SimpleJob",
"queue_name" => "simple",
"arguments" => nil
"arguments" => ['foo-arg-1', 'foo-arg-2'],
}]
)
end
Expand All @@ -31,7 +31,7 @@
"queue" => "simple",
"description" => "It's a simple job.",
"every" => "30s",
"args" => [nil],
"args" => ['foo-arg-1', 'foo-arg-2'],
)
end
end
Expand All @@ -50,7 +50,7 @@
"args" => [{
"job_class" => "SimpleJob",
"queue_name" => "simple",
"arguments" => nil
"arguments" => "foo-argument",
}]
)
end
Expand Down Expand Up @@ -98,7 +98,7 @@
"args" => [{
"job_class" => "MyScheduleNameIsClassNameJob",
"queue_name" => "myscheduledjobqueue",
"arguments" => nil
"arguments" => [nil]
}]
)
end
Expand Down
3 changes: 2 additions & 1 deletion spec/fixtures/simple_job.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"every": "30s",
"queue": "simple",
"class": "SimpleJob",
"description": "It's a simple job."
"description": "It's a simple job.",
"arguments": "foo-argument"
}
}
3 changes: 2 additions & 1 deletion spec/fixtures/simple_job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ simple_job:
queue: "simple"
class: "SimpleJob"
args:
-
- foo-arg-1
- foo-arg-2
description: "It's a simple job."

0 comments on commit d1c12f1

Please sign in to comment.