From d1c12f106fcde2a8fdc8356b3297396a804ca7e6 Mon Sep 17 00:00:00 2001 From: ximus Date: Wed, 6 Apr 2016 15:11:47 -0700 Subject: [PATCH] Deprecate arguments key in schedule --- lib/active_scheduler/resque_wrapper.rb | 10 +++++++++- spec/active_scheduler/resque_wrapper_spec.rb | 8 ++++---- spec/fixtures/simple_job.json | 3 ++- spec/fixtures/simple_job.yaml | 3 ++- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/active_scheduler/resque_wrapper.rb b/lib/active_scheduler/resque_wrapper.rb index a040354..7e39e22 100644 --- a/lib/active_scheduler/resque_wrapper.rb +++ b/lib/active_scheduler/resque_wrapper.rb @@ -20,6 +20,14 @@ 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', @@ -27,7 +35,7 @@ def self.wrap(schedule) args: [{ job_class: class_name, queue_name: queue, - arguments: opts[:arguments] + arguments: args }] } diff --git a/spec/active_scheduler/resque_wrapper_spec.rb b/spec/active_scheduler/resque_wrapper_spec.rb index bb0cc5c..b416319 100644 --- a/spec/active_scheduler/resque_wrapper_spec.rb +++ b/spec/active_scheduler/resque_wrapper_spec.rb @@ -18,7 +18,7 @@ "args" => [{ "job_class" => "SimpleJob", "queue_name" => "simple", - "arguments" => nil + "arguments" => ['foo-arg-1', 'foo-arg-2'], }] ) end @@ -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 @@ -50,7 +50,7 @@ "args" => [{ "job_class" => "SimpleJob", "queue_name" => "simple", - "arguments" => nil + "arguments" => "foo-argument", }] ) end @@ -98,7 +98,7 @@ "args" => [{ "job_class" => "MyScheduleNameIsClassNameJob", "queue_name" => "myscheduledjobqueue", - "arguments" => nil + "arguments" => [nil] }] ) end diff --git a/spec/fixtures/simple_job.json b/spec/fixtures/simple_job.json index 29da4f6..4523ace 100644 --- a/spec/fixtures/simple_job.json +++ b/spec/fixtures/simple_job.json @@ -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" } } diff --git a/spec/fixtures/simple_job.yaml b/spec/fixtures/simple_job.yaml index 0cc86f4..9b42599 100644 --- a/spec/fixtures/simple_job.yaml +++ b/spec/fixtures/simple_job.yaml @@ -3,5 +3,6 @@ simple_job: queue: "simple" class: "SimpleJob" args: - - + - foo-arg-1 + - foo-arg-2 description: "It's a simple job."