mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Make que report back its job_id to provider_job_id
Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
This commit is contained in:
parent
52d131826e
commit
29fcbc2ea0
3 changed files with 13 additions and 20 deletions
|
@ -1,14 +1,9 @@
|
|||
* Allow `Sidekiq` to report the job id back to `ActiveJob::Base` as
|
||||
`provider_job_id`
|
||||
|
||||
*Jeroen van Baarsen*
|
||||
|
||||
* Allow `DelayedJob` to report id back to `ActiveJob::Base` as
|
||||
`provider_job_id`.
|
||||
* Allow `DelayedJob`, `Sidekiq` and `que` to report the job id back to
|
||||
`ActiveJob::Base` as `provider_job_id`.
|
||||
|
||||
Fixes #18821.
|
||||
|
||||
*Kevin Deisz*
|
||||
*Kevin Deisz* And *Jeroen van Baarsen*
|
||||
|
||||
* `assert_enqueued_jobs` and `assert_performed_jobs` in block form use the
|
||||
given number as expected value. This makes the error message much easier to
|
||||
|
|
|
@ -16,11 +16,15 @@ module ActiveJob
|
|||
# Rails.application.config.active_job.queue_adapter = :que
|
||||
class QueAdapter
|
||||
def enqueue(job) #:nodoc:
|
||||
JobWrapper.enqueue job.serialize
|
||||
que_job = JobWrapper.enqueue job.serialize
|
||||
job.provider_job_id = que_job.attrs["job_id"]
|
||||
que_job
|
||||
end
|
||||
|
||||
def enqueue_at(job, timestamp) #:nodoc:
|
||||
JobWrapper.enqueue job.serialize, run_at: Time.at(timestamp)
|
||||
que_job = JobWrapper.enqueue job.serialize, run_at: Time.at(timestamp)
|
||||
job.provider_job_id = que_job.attrs["job_id"]
|
||||
que_job
|
||||
end
|
||||
|
||||
class JobWrapper < Que::Job #:nodoc:
|
||||
|
|
|
@ -56,19 +56,13 @@ class QueuingTest < ActiveSupport::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
test 'should supply a provider_job_id to DelayedJob' do
|
||||
skip unless adapter_is?(:delayed_job)
|
||||
test 'should supply a provider_job_id when available' do
|
||||
skip unless adapter_is?(:sidekiq) || adapter_is?(:que) || adapter_is?(:delayed_job)
|
||||
test_job = TestJob.perform_later @id
|
||||
assert_kind_of Fixnum, test_job.provider_job_id
|
||||
end
|
||||
|
||||
test 'should supply a provider_job_id to Sidekiq' do
|
||||
skip unless adapter_is?(:sidekiq)
|
||||
test_job = TestJob.perform_later @id
|
||||
refute test_job.provider_job_id.nil?, "Provider job id should be set by Sidekiq"
|
||||
refute test_job.provider_job_id.nil?, "Provider job id should be set by provider"
|
||||
|
||||
delayed_test_job = TestJob.set(wait: 1.minute).perform_later @id
|
||||
refute delayed_test_job.provider_job_id.nil?,
|
||||
"Provider job id should by set for delayed jobs by sidekiq"
|
||||
"Provider job id should by set for delayed jobs by provider"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue