diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2016-07-28 01:08:22 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-28 01:08:22 -0300 |
commit | 410a21416ee2817aeea653d48f624d390f336b5f (patch) | |
tree | 1e4f023f0235660286ea91876efc8c8d6c37a5a7 /activejob/test | |
parent | 303353fc95ed9f1ada74a7bfac7e8304745a7fee (diff) | |
parent | 80e825915c7ff638f4b668a7cca1be46903cb433 (diff) | |
download | rails-410a21416ee2817aeea653d48f624d390f336b5f.tar.gz rails-410a21416ee2817aeea653d48f624d390f336b5f.tar.bz2 rails-410a21416ee2817aeea653d48f624d390f336b5f.zip |
Merge pull request #25961 from Azzurrio/master
Fix accessing provider_job_id inside active jobs for sidekiq adapter
Diffstat (limited to 'activejob/test')
-rw-r--r-- | activejob/test/integration/queuing_test.rb | 9 | ||||
-rw-r--r-- | activejob/test/jobs/provider_jid_job.rb | 7 |
2 files changed, 16 insertions, 0 deletions
diff --git a/activejob/test/integration/queuing_test.rb b/activejob/test/integration/queuing_test.rb index 40f27500a5..ab3de3a8b9 100644 --- a/activejob/test/integration/queuing_test.rb +++ b/activejob/test/integration/queuing_test.rb @@ -1,6 +1,7 @@ require 'helper' require 'jobs/logging_job' require 'jobs/hello_job' +require 'jobs/provider_jid_job' require 'active_support/core_ext/numeric/time' class QueuingTest < ActiveSupport::TestCase @@ -34,6 +35,14 @@ class QueuingTest < ActiveSupport::TestCase end end + test 'should access provider_job_id inside Sidekiq job' do + skip unless adapter_is?(:sidekiq) + Sidekiq::Testing.inline! do + job = ::ProviderJidJob.perform_later + assert_equal "Provider Job ID: #{job.provider_job_id}", JobBuffer.last_value + end + end + test 'should not run job enqueued in the future' do begin TestJob.set(wait: 10.minutes).perform_later @id diff --git a/activejob/test/jobs/provider_jid_job.rb b/activejob/test/jobs/provider_jid_job.rb new file mode 100644 index 0000000000..e4f585fa94 --- /dev/null +++ b/activejob/test/jobs/provider_jid_job.rb @@ -0,0 +1,7 @@ +require_relative '../support/job_buffer' + +class ProviderJidJob < ActiveJob::Base + def perform + JobBuffer.add("Provider Job ID: #{provider_job_id}") + end +end |