From 7efd77fae58a02c6014211a8f2f9bcce3f4844cc Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 2 Aug 2016 14:26:56 -0700 Subject: Fix tests against ActiveSupport::Durations --- activejob/lib/active_job/exceptions.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'activejob/lib/active_job/exceptions.rb') diff --git a/activejob/lib/active_job/exceptions.rb b/activejob/lib/active_job/exceptions.rb index 5488a86756..acbe0c4057 100644 --- a/activejob/lib/active_job/exceptions.rb +++ b/activejob/lib/active_job/exceptions.rb @@ -101,16 +101,21 @@ module ActiveJob end private - def determine_delay(seconds_or_algorithm) - case seconds_or_algorithm + def determine_delay(seconds_or_duration_or_algorithm) + case seconds_or_duration_or_algorithm when :exponentially_longer (executions ** 4) + 2 + when ActiveSupport::Duration + duration = seconds_or_duration_or_algorithm + duration.to_i when Integer - seconds = seconds_or_algorithm + seconds = seconds_or_duration_or_algorithm seconds when Proc - algorithm = seconds_or_algorithm + algorithm = seconds_or_duration_or_algorithm algorithm.call(executions) + else + raise "Couldn't determine a delay based on #{seconds_or_duration_or_algorithm.inspect}" end end end -- cgit v1.2.3