diff options
author | Patrik Bóna <patrik.bona@mrhead.sk> | 2019-04-12 17:24:05 +0200 |
---|---|---|
committer | Patrik Bóna <patrik.bona@mrhead.sk> | 2019-04-12 17:47:08 +0200 |
commit | 3a7fa10603b6842251a6e8b22c302253ae7999ab (patch) | |
tree | fa7654e2edcafae7194c0385740a51bbcb30c6a7 /activejob/test | |
parent | ef0c5fe0d98ad1b1b27fe3d6d19ae62aed3e8aa1 (diff) | |
download | rails-3a7fa10603b6842251a6e8b22c302253ae7999ab.tar.gz rails-3a7fa10603b6842251a6e8b22c302253ae7999ab.tar.bz2 rails-3a7fa10603b6842251a6e8b22c302253ae7999ab.zip |
Use individual execution counters when calculating retry delay
Individual execution counters were introduced in #34352. However
`#determine_delay` which is used to calculate retry delay still uses the
global counter. This commit fixes it.
Diffstat (limited to 'activejob/test')
-rw-r--r-- | activejob/test/cases/exceptions_test.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/activejob/test/cases/exceptions_test.rb b/activejob/test/cases/exceptions_test.rb index c88162bf58..840f4d40b5 100644 --- a/activejob/test/cases/exceptions_test.rb +++ b/activejob/test/cases/exceptions_test.rb @@ -140,6 +140,26 @@ class ExceptionsTest < ActiveSupport::TestCase ], JobBuffer.values end + test "use individual execution timers when calculating retry delay" do + travel_to Time.now + + exceptions_to_raise = %w(ExponentialWaitTenAttemptsError CustomWaitTenAttemptsError ExponentialWaitTenAttemptsError CustomWaitTenAttemptsError) + + RetryJob.perform_later exceptions_to_raise, 5, :log_scheduled_at + + assert_equal [ + "Raised ExponentialWaitTenAttemptsError for the 1st time", + "Next execution scheduled at #{(Time.now + 3.seconds).to_f}", + "Raised CustomWaitTenAttemptsError for the 2nd time", + "Next execution scheduled at #{(Time.now + 2.seconds).to_f}", + "Raised ExponentialWaitTenAttemptsError for the 3rd time", + "Next execution scheduled at #{(Time.now + 18.seconds).to_f}", + "Raised CustomWaitTenAttemptsError for the 4th time", + "Next execution scheduled at #{(Time.now + 4.seconds).to_f}", + "Successfully completed job" + ], JobBuffer.values + end + test "successfully retry job throwing one of two retryable exceptions" do RetryJob.perform_later "SecondRetryableErrorOfTwo", 3 |