Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix DateTime comparison with DateTime::Infinity object

Fixes #16406

Conflicts:
	activesupport/CHANGELOG.md
  • Loading branch information...
commit a64763b43f7974201f2aea7b8b7aa9e5839e84b6 1 parent 999bed0
@rafaelfranca rafaelfranca authored
View
4 activesupport/CHANGELOG.md
@@ -1,3 +1,7 @@
+* Fix DateTime comparison with DateTime::Infinity object.
+
+ *Rafael Mendonça França*
+
* Fixed a compatibility issue with the `Oj` gem when cherry-picking the file
`active_support/core_ext/object/json` without requiring `active_support/json`.
View
4 activesupport/lib/active_support/core_ext/date_time/calculations.rb
@@ -151,7 +151,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.