aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2016-08-02 14:26:56 -0700
committerDavid Heinemeier Hansson <david@loudthinking.com>2016-08-02 14:27:01 -0700
commit7efd77fae58a02c6014211a8f2f9bcce3f4844cc (patch)
treee8d188ce1aba65e0d2627ed5d17ac34956bf32bf /activejob/lib
parent2762ebd84629ccc39a9959ecf15c9f82c1d283b3 (diff)
downloadrails-7efd77fae58a02c6014211a8f2f9bcce3f4844cc.tar.gz
rails-7efd77fae58a02c6014211a8f2f9bcce3f4844cc.tar.bz2
rails-7efd77fae58a02c6014211a8f2f9bcce3f4844cc.zip
Fix tests against ActiveSupport::Durations
Diffstat (limited to 'activejob/lib')
-rw-r--r--activejob/lib/active_job/exceptions.rb13
1 files changed, 9 insertions, 4 deletions
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