Skip to content
Browse files

Fix iterating over DateTime by doing strict checking for Time objects

- Fixes #13667

(cherry picked from commit 1842a69)
  • Loading branch information...
1 parent 7d3a336 commit ecd07076868d57aeb0b5f55595161794f8f75944 @prathamesh-sonpatki prathamesh-sonpatki committed with pixeltrix Jan 10, 2014
View
3 activesupport/lib/active_support/core_ext/range/each.rb
@@ -1,5 +1,4 @@
require 'active_support/core_ext/module/aliasing'
-require 'active_support/core_ext/object/acts_like'
class Range #:nodoc:
@@ -17,7 +16,7 @@ def step_with_time_with_zone(n = 1, &block)
private
def ensure_iteration_allowed
- if first.acts_like?(:time)
+ if first.is_a?(Time)
raise TypeError, "can't iterate from #{first.class}"
end
end
View
4 activesupport/test/core_ext/range_ext_test.rb
@@ -112,4 +112,8 @@ def test_include_on_time_with_zone
end
end
+ def test_date_time_with_each
+ datetime = DateTime.now
+ assert ((datetime - 1.hour)..datetime).each {}
+ end
end

0 comments on commit ecd0707

Please sign in to comment.
Something went wrong with that request. Please try again.