From 111227c0dfb72b060428063e35d865b62338654a Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 2 Aug 2016 12:28:16 -0700 Subject: Please Rubocup --- activejob/lib/active_job/exceptions.rb | 6 +++--- activejob/test/cases/exceptions_test.rb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/activejob/lib/active_job/exceptions.rb b/activejob/lib/active_job/exceptions.rb index 33388816e9..5488a86756 100644 --- a/activejob/lib/active_job/exceptions.rb +++ b/activejob/lib/active_job/exceptions.rb @@ -15,7 +15,7 @@ module ActiveJob # the exception bubble up. # # ==== Options - # * :wait - Re-enqueues the job with a delay specified either in seconds (default: 3 seconds), + # * :wait - Re-enqueues the job with a delay specified either in seconds (default: 3 seconds), # as a computing proc that the number of executions so far as an argument, or as a symbol reference of # :exponentially_longer<>, which applies the wait algorithm of (executions ** 4) + 2 # (first wait 3s, then 18s, then 83s, etc) @@ -45,7 +45,7 @@ module ActiveJob if executions < attempts logger.error "Retrying #{self.class} in #{wait} seconds, due to a #{exception}. The original exception was #{error.cause.inspect}." retry_job wait: determine_delay(wait), queue: queue, priority: priority - else + else if block_given? yield exception else @@ -112,6 +112,6 @@ module ActiveJob algorithm = seconds_or_algorithm algorithm.call(executions) end - end + end end end diff --git a/activejob/test/cases/exceptions_test.rb b/activejob/test/cases/exceptions_test.rb index 3df4f04bec..9ad73ff93c 100644 --- a/activejob/test/cases/exceptions_test.rb +++ b/activejob/test/cases/exceptions_test.rb @@ -44,7 +44,7 @@ class ExceptionsTest < ActiveSupport::TestCase RetryJob.perform_later 'DiscardableError', 2 assert_equal "Raised DiscardableError for the 1st time", JobBuffer.last_value end - + test "custom handling of job that exceeds retry attempts" do RetryJob.perform_later 'CustomCatchError', 6 assert_equal "Dealt with a job that failed to retry in a custom way", JobBuffer.last_value @@ -87,4 +87,4 @@ class ExponentiallyBackoffExceptionsTest < ActiveJob::TestCase end end end -end \ No newline at end of file +end -- cgit v1.2.3