提交 1842a692 编写于 作者: P Prathamesh Sonpatki

Fix iterating over DateTime by doing strict checking for Time objects

- Fixes #13667
上级 e633cdb3
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
......
......@@ -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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册