Skip to content

Commit 59eb7ed

Browse files
committed
Remove deprecated support to use Range#include? to check the inclusion of a value in a date time range is deprecated
1 parent 93c3594 commit 59eb7ed

File tree

5 files changed

+12
-33
lines changed

5 files changed

+12
-33
lines changed

activesupport/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
* Remove deprecated support to use `Range#include?` to check the inclusion of a value in
2+
a date time range is deprecated.
3+
4+
*Rafael Mendonça França*
5+
16
* Remove deprecated `URI.parser`.
27

38
*Rafael Mendonça França*

activesupport/lib/active_support/core_ext/range.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22

33
require "active_support/core_ext/range/conversions"
44
require "active_support/core_ext/range/compare_range"
5-
require "active_support/core_ext/range/include_time_with_zone"
65
require "active_support/core_ext/range/overlaps"
76
require "active_support/core_ext/range/each"
Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,7 @@
11
# frozen_string_literal: true
22

3-
require "active_support/time_with_zone"
4-
require "active_support/deprecation"
5-
6-
module ActiveSupport
7-
module IncludeTimeWithZone # :nodoc:
8-
# Extends the default Range#include? to support ActiveSupport::TimeWithZone.
9-
#
10-
# (1.hour.ago..1.hour.from_now).include?(Time.current) # => true
11-
#
12-
def include?(value)
13-
if self.begin.is_a?(TimeWithZone) || self.end.is_a?(TimeWithZone)
14-
ActiveSupport::Deprecation.warn(<<-MSG.squish)
15-
Using `Range#include?` to check the inclusion of a value in
16-
a date time range is deprecated.
17-
It is recommended to use `Range#cover?` instead of `Range#include?` to
18-
check the inclusion of a value in a date time range.
19-
MSG
20-
cover?(value)
21-
else
22-
super
23-
end
24-
end
25-
end
26-
end
3+
# frozen_string_literal: true
274

28-
Range.prepend(ActiveSupport::IncludeTimeWithZone)
5+
ActiveSupport::Deprecation.warn(<<-MSG.squish)
6+
`active_support/core_ext/range/include_time_with_zone` is deprecated and will be removed in Rails 7.1.
7+
MSG

activesupport/test/core_ext/range_ext_test.rb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,6 @@ def test_cover_on_time_with_zone
182182
assert ((twz - 1.hour)..twz).cover?(twz)
183183
end
184184

185-
def test_include_on_time_with_zone
186-
twz = ActiveSupport::TimeWithZone.new(nil, ActiveSupport::TimeZone["Eastern Time (US & Canada)"], Time.utc(2006, 11, 28, 10, 30))
187-
assert_deprecated do
188-
((twz - 1.hour)..twz).include?(twz)
189-
end
190-
end
191-
192185
def test_case_equals_on_time_with_zone
193186
twz = ActiveSupport::TimeWithZone.new(nil, ActiveSupport::TimeZone["Eastern Time (US & Canada)"], Time.utc(2006, 11, 28, 10, 30))
194187
assert ((twz - 1.hour)..twz) === twz

guides/source/7_0_release_notes.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@ Please refer to the [Changelog][active-support] for detailed changes.
233233

234234
* Remove deprecated `URI.parser`.
235235

236+
* Remove deprecated support to use `Range#include?` to check the inclusion of a value in
237+
a date time range is deprecated.
238+
236239
### Deprecations
237240

238241
### Notable changes

0 commit comments

Comments
 (0)