diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2018-12-05 11:24:19 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-05 11:24:19 -0500 |
commit | 299a213a738e078c6fbddd488a711ea9bb066fe2 (patch) | |
tree | 2871f9600b1526625b359107e29c84970fdc18c8 /activejob/test/cases | |
parent | 647665110f49935b30e29ac09ecfca3701e76041 (diff) | |
parent | ee9fc120242b83c64bf77af1b72082ac76319332 (diff) | |
download | rails-299a213a738e078c6fbddd488a711ea9bb066fe2.tar.gz rails-299a213a738e078c6fbddd488a711ea9bb066fe2.tar.bz2 rails-299a213a738e078c6fbddd488a711ea9bb066fe2.zip |
Merge pull request #33992 from kirs/enqueue-return-false
Make AJ::Base#enqueue return false if the job wasn't enqueued
Diffstat (limited to 'activejob/test/cases')
-rw-r--r-- | activejob/test/cases/callbacks_test.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/activejob/test/cases/callbacks_test.rb b/activejob/test/cases/callbacks_test.rb index df6ce16858..267d58a7c8 100644 --- a/activejob/test/cases/callbacks_test.rb +++ b/activejob/test/cases/callbacks_test.rb @@ -2,6 +2,7 @@ require "helper" require "jobs/callback_job" +require "jobs/abort_before_enqueue_job" require "active_support/core_ext/object/inclusion" @@ -22,4 +23,32 @@ class CallbacksTest < ActiveSupport::TestCase assert "CallbackJob ran around_enqueue_start".in? enqueued_callback_job.history assert "CallbackJob ran around_enqueue_stop".in? enqueued_callback_job.history end + + test "#enqueue returns false when before_enqueue aborts callback chain and return_false_on_aborted_enqueue = true" do + begin + prev = ActiveJob::Base.return_false_on_aborted_enqueue + ActiveJob::Base.return_false_on_aborted_enqueue = true + assert_equal false, AbortBeforeEnqueueJob.new.enqueue + ensure + ActiveJob::Base.return_false_on_aborted_enqueue = prev + end + end + + test "#enqueue returns self when before_enqueue aborts callback chain and return_false_on_aborted_enqueue = false" do + begin + prev = ActiveJob::Base.return_false_on_aborted_enqueue + ActiveJob::Base.return_false_on_aborted_enqueue = false + job = AbortBeforeEnqueueJob.new + assert_deprecated do + assert_equal job, job.enqueue + end + ensure + ActiveJob::Base.return_false_on_aborted_enqueue = prev + end + end + + test "#enqueue returns self when the job was enqueued" do + job = CallbackJob.new + assert_equal job, job.enqueue + end end |