Skip to content

Commit 096fb3b

Browse files
authored
Merge pull request rails#53929 from lovro-bikic/feature/allow-iterating-time-with-zone
Remove monkey patches of `Range#each` and `Range#step`
2 parents 6a88a10 + 100c316 commit 096fb3b

File tree

3 files changed

+12
-29
lines changed

3 files changed

+12
-29
lines changed

activesupport/lib/active_support/core_ext/range.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
require "active_support/core_ext/range/conversions"
44
require "active_support/core_ext/range/compare_range"
55
require "active_support/core_ext/range/overlap"
6-
require "active_support/core_ext/range/each"

activesupport/lib/active_support/core_ext/range/each.rb

Lines changed: 0 additions & 24 deletions
This file was deleted.

activesupport/test/core_ext/range_ext_test.rb

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,18 @@ def test_each_on_time_with_zone
253253
end
254254
end
255255

256-
def test_step_on_time_with_zone
257-
twz = ActiveSupport::TimeWithZone.new(nil, ActiveSupport::TimeZone["Eastern Time (US & Canada)"], Time.utc(2006, 11, 28, 10, 30))
258-
assert_raises TypeError do
259-
((twz - 1.hour)..twz).step(1) { }
256+
if RUBY_VERSION < "3.4"
257+
def test_step_on_time_with_zone
258+
twz = ActiveSupport::TimeWithZone.new(nil, ActiveSupport::TimeZone["Eastern Time (US & Canada)"], Time.utc(2006, 11, 28, 10, 30))
259+
assert_raises TypeError do
260+
((twz - 1.hour)..twz).step(1) { }
261+
end
262+
end
263+
else
264+
def test_step_on_time_with_zone
265+
twz = ActiveSupport::TimeWithZone.new(nil, ActiveSupport::TimeZone["Eastern Time (US & Canada)"], Time.utc(2006, 11, 28, 10, 30))
266+
267+
assert_equal [twz, twz + 15.minutes, twz + 30.minutes], (twz..).step(15.minutes).first(3)
260268
end
261269
end
262270

0 commit comments

Comments
 (0)