aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2016-08-23 00:38:42 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2016-08-23 00:39:39 -0300
commit7f4b16ed83b878df6a68d471d2d5e7c719b40261 (patch)
treef290d32680e741631e65af5e67d07559209f81b2
parent97507329d6248fa7ade24ff540c3637010bdb6c7 (diff)
parent9f6461a28cb5241b478884e84882cca8a0897cda (diff)
downloadrails-7f4b16ed83b878df6a68d471d2d5e7c719b40261.tar.gz
rails-7f4b16ed83b878df6a68d471d2d5e7c719b40261.tar.bz2
rails-7f4b16ed83b878df6a68d471d2d5e7c719b40261.zip
Merge pull request #26205 from pedaling-corp/fix/active-job-resque
Add @queue variable to JobWrapper
-rw-r--r--activejob/CHANGELOG.md10
-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, 2 deletions
diff --git a/activejob/CHANGELOG.md b/activejob/CHANGELOG.md
index 585ade7229..9bf397af14 100644
--- a/activejob/CHANGELOG.md
+++ b/activejob/CHANGELOG.md
@@ -1,10 +1,15 @@
-## Rails 5.1.0.alpha ##
+* 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*
* Yield the job instance so you have access to things like `job.arguments` on the custom logic after retries fail.
*DHH*
-* Added declarative exception handling via `ActiveJob::Base.retry_on` and `ActiveJob::Base.discard_on`.
+* Added declarative exception handling via `ActiveJob::Base.retry_on` and `ActiveJob::Base.discard_on`.
Examples:
@@ -24,4 +29,5 @@
*DHH*
+
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