aboutsummaryrefslogtreecommitdiffstats
path: root/activejob
diff options
context:
space:
mode:
authorInJung Chung <mu29gl@gmail.com>2016-08-18 16:44:28 +0900
committerInJung Chung <mu29gl@gmail.com>2016-08-19 17:10:27 +0900
commit9f6461a28cb5241b478884e84882cca8a0897cda (patch)
tree3c85deca9eb6fb2d130a2586eb327a00ea88a50c /activejob
parentfd0c33d7cc8dd06083f543cf531ab1f4c52c6a6e (diff)
downloadrails-9f6461a28cb5241b478884e84882cca8a0897cda.tar.gz
rails-9f6461a28cb5241b478884e84882cca8a0897cda.tar.bz2
rails-9f6461a28cb5241b478884e84882cca8a0897cda.zip
Added instance variable `@queue` to JobWrapper.
This will fix issues in [resque-scheduler](https://github.com/resque/resque-scheduler) `#job_to_hash` method, so we can use `#enqueue_delayed_selection`, `#remove_delayed` method in resque-scheduler smoothly.
Diffstat (limited to 'activejob')
-rw-r--r--activejob/CHANGELOG.md8
-rw-r--r--activejob/lib/active_job/queue_adapters/resque_adapter.rb1
-rw-r--r--activejob/test/integration/queuing_test.rb7
3 files changed, 16 insertions, 0 deletions
diff --git a/activejob/CHANGELOG.md b/activejob/CHANGELOG.md
index 585ade7229..653149b6ee 100644
--- a/activejob/CHANGELOG.md
+++ b/activejob/CHANGELOG.md
@@ -24,4 +24,12 @@
*DHH*
+* Added instance variable `@queue` to JobWrapper.
+
+ This will fix issues in [resque-scheduler](https://github.com/resque/resque-scheduler) `#job_to_hash` method,
+ so we can use `#enqueue_delayed_selection`, `#remove_delayed` method in resque-scheduler smoothly.
+
+ *mu29*
+
+
Please check [5-0-stable](https://github.com/rails/rails/blob/5-0-stable/activejob/CHANGELOG.md) for previous changes.
diff --git a/activejob/lib/active_job/queue_adapters/resque_adapter.rb b/activejob/lib/active_job/queue_adapters/resque_adapter.rb
index 8620401cc1..2df157ef89 100644
--- a/activejob/lib/active_job/queue_adapters/resque_adapter.rb
+++ b/activejob/lib/active_job/queue_adapters/resque_adapter.rb
@@ -27,6 +27,7 @@ module ActiveJob
# Rails.application.config.active_job.queue_adapter = :resque
class ResqueAdapter
def enqueue(job) #:nodoc:
+ JobWrapper.instance_variable_set(:@queue, job.queue_name)
Resque.enqueue_to job.queue_name, JobWrapper, job.serialize
end
diff --git a/activejob/test/integration/queuing_test.rb b/activejob/test/integration/queuing_test.rb
index 41b6b9cd6b..2669c52a1c 100644
--- a/activejob/test/integration/queuing_test.rb
+++ b/activejob/test/integration/queuing_test.rb
@@ -43,6 +43,13 @@ class QueuingTest < ActiveSupport::TestCase
end
end
+ test "resque JobWrapper should have instance variable queue" do
+ skip unless adapter_is?(:resque)
+ job = ::HelloJob.set(wait: 5.seconds).perform_later
+ hash = Resque.decode(Resque.find_delayed_selection { true }[0])
+ assert_equal hash["queue"], job.queue_name
+ end
+
test "should not run job enqueued in the future" do
begin
TestJob.set(wait: 10.minutes).perform_later @id