1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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.
This commit is contained in:
InJung Chung 2016-08-18 16:44:28 +09:00
parent fd0c33d7cc
commit 9f6461a28c
3 changed files with 16 additions and 0 deletions

View file

@ -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.

View file

@ -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

View file

@ -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