diff options
author | Andrew White <andyw@pixeltrix.co.uk> | 2014-01-12 00:24:50 -0800 |
---|---|---|
committer | Andrew White <andyw@pixeltrix.co.uk> | 2014-01-12 00:24:50 -0800 |
commit | 75c271198ac2c94c58b46389383aef2df1afc572 (patch) | |
tree | 7928faf768f02b32f657753688e5d2fb1b1fe791 | |
parent | 4ae3da66f71fac4fb5cd5796e7460dc4e982891b (diff) | |
parent | 1842a6920f6205262407ca893d31577f050b6b87 (diff) | |
download | rails-75c271198ac2c94c58b46389383aef2df1afc572.tar.gz rails-75c271198ac2c94c58b46389383aef2df1afc572.tar.bz2 rails-75c271198ac2c94c58b46389383aef2df1afc572.zip |
Merge pull request #13668 from prathamesh-sonpatki/issue-13667
Fix iterating over DateTime by doing strict checking for Time objects
-rw-r--r-- | activesupport/lib/active_support/core_ext/range/each.rb | 3 | ||||
-rw-r--r-- | activesupport/test/core_ext/range_ext_test.rb | 4 |
2 files changed, 5 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/core_ext/range/each.rb b/activesupport/lib/active_support/core_ext/range/each.rb index d51ea2e944..ecef78f55f 100644 --- a/activesupport/lib/active_support/core_ext/range/each.rb +++ b/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 @@ class Range #:nodoc: 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 diff --git a/activesupport/test/core_ext/range_ext_test.rb b/activesupport/test/core_ext/range_ext_test.rb index 6d6afc85c4..150e6b65fb 100644 --- a/activesupport/test/core_ext/range_ext_test.rb +++ b/activesupport/test/core_ext/range_ext_test.rb @@ -112,4 +112,8 @@ class RangeTest < ActiveSupport::TestCase end end + def test_date_time_with_each + datetime = DateTime.now + assert ((datetime - 1.hour)..datetime).each {} + end end |