Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix DateTime comparison with DateTime::Infinity object

Fixes #16406

Conflicts:
	activesupport/CHANGELOG.md
  • Loading branch information...
commit 17db438d958cba9d6de3225d61ca34e7b8a1ef20 1 parent 6d95e04
@rafaelfranca rafaelfranca authored
View
5 activesupport/CHANGELOG.md
@@ -1,4 +1,9 @@
+* Fix DateTime comparison with DateTime::Infinity object.
+
+ *Rafael Mendonça França*
+
* Make Dependencies pass a name to NameError error.
+
*arthurnn*, *Yuki Nishijima*
View
4 activesupport/lib/active_support/core_ext/date_time/calculations.rb
@@ -158,7 +158,9 @@ def utc_offset
# 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
View
1  activesupport/test/core_ext/range_ext_test.rb
@@ -16,6 +16,7 @@ def test_to_s_from_times
def test_date_range
assert_instance_of Range, DateTime.new..DateTime.new
assert_instance_of Range, DateTime::Infinity.new..DateTime::Infinity.new
+ assert_instance_of Range, DateTime.new..DateTime::Infinity.new
end
def test_overlaps_last_inclusive
Please sign in to comment.
Something went wrong with that request. Please try again.