aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/test/jobs/retry_job.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activejob/test/jobs/retry_job.rb')
-rw-r--r--activejob/test/jobs/retry_job.rb14
1 files changed, 3 insertions, 11 deletions
diff --git a/activejob/test/jobs/retry_job.rb b/activejob/test/jobs/retry_job.rb
index 2d19d4c41e..3b0dce1a3c 100644
--- a/activejob/test/jobs/retry_job.rb
+++ b/activejob/test/jobs/retry_job.rb
@@ -18,7 +18,7 @@ class CustomDiscardableError < StandardError; end
class RetryJob < ActiveJob::Base
retry_on DefaultsError
- retry_on FirstRetryableErrorOfTwo, SecondRetryableErrorOfTwo
+ retry_on FirstRetryableErrorOfTwo, SecondRetryableErrorOfTwo, attempts: 4
retry_on LongWaitError, wait: 1.hour, attempts: 10
retry_on ShortWaitTenAttemptsError, wait: 1.second, attempts: 10
retry_on ExponentialWaitTenAttemptsError, wait: :exponentially_longer, attempts: 10
@@ -31,7 +31,8 @@ class RetryJob < ActiveJob::Base
discard_on(CustomDiscardableError) { |job, error| JobBuffer.add("Dealt with a job that was discarded in a custom way. Message: #{error.message}") }
def perform(raising, attempts)
- if executions < attempts
+ raising = raising.shift if raising.is_a?(Array)
+ if raising && executions < attempts
JobBuffer.add("Raised #{raising} for the #{executions.ordinalize} time")
raise raising.constantize
else
@@ -39,12 +40,3 @@ class RetryJob < ActiveJob::Base
end
end
end
-
-class ExceptionRetryJob < ActiveJob::Base
- retry_on FirstRetryableErrorOfTwo, SecondRetryableErrorOfTwo, attempts: 4
- retry_on DefaultsError
-
- def perform(exceptions)
- raise exceptions.shift.constantize.new unless exceptions.empty?
- end
-end