aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/date_time
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-01-14 03:32:34 -0800
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-08-06 22:43:37 -0300
commitca9736e78ca9348e785a5c78c8cc085c0c2d4731 (patch)
tree3f2eab0aee43143945e89a7b3a659dbe158c4c73 /activesupport/lib/active_support/core_ext/date_time
parentd25fe31c40928712b5e08fe0afb567c3bc88eddf (diff)
downloadrails-ca9736e78ca9348e785a5c78c8cc085c0c2d4731.tar.gz
rails-ca9736e78ca9348e785a5c78c8cc085c0c2d4731.tar.bz2
rails-ca9736e78ca9348e785a5c78c8cc085c0c2d4731.zip
Fix DateTime comparison with DateTime::Infinity object
Fixes #16406
Diffstat (limited to 'activesupport/lib/active_support/core_ext/date_time')
-rw-r--r--activesupport/lib/active_support/core_ext/date_time/calculations.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/date_time/calculations.rb b/activesupport/lib/active_support/core_ext/date_time/calculations.rb
index 289ca12b5e..dc4e767e9d 100644
--- a/activesupport/lib/active_support/core_ext/date_time/calculations.rb
+++ b/activesupport/lib/active_support/core_ext/date_time/calculations.rb
@@ -161,7 +161,9 @@ class DateTime
# Layers additional behavior on DateTime#<=> so that Time and
# ActiveSupport::TimeWithZone instances can be compared with a DateTime.
def <=>(other)
- if other.respond_to? :to_datetime
+ if other.kind_of?(Infinity)
+ super
+ elsif other.respond_to? :to_datetime
super other.to_datetime
else
nil