Skip to content

Commit c7b9bb1

Browse files
committed
Drop support to Ruby 3.1
Rails 8 will require Ruby 3.2.0 or newer.
1 parent 3997ed6 commit c7b9bb1

File tree

26 files changed

+83
-159
lines changed

26 files changed

+83
-159
lines changed

Gemfile

-6
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,4 @@ end
172172
gem "tzinfo-data", platforms: [:windows, :jruby]
173173
gem "wdm", ">= 0.1.0", platforms: [:windows]
174174

175-
# The error_highlight gem only works on CRuby 3.1 or later.
176-
# Also, Rails depends on a new API available since error_highlight 0.4.0.
177-
# (Note that Ruby 3.1 bundles error_highlight 0.3.0.)
178-
if RUBY_VERSION < "3.2"
179-
gem "error_highlight", ">= 0.4.0", platforms: [:ruby]
180-
end
181175
gem "launchy"

actioncable/actioncable.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
99
s.summary = "WebSocket framework for Rails."
1010
s.description = "Structure many real-time application concerns into channels over a single WebSocket connection."
1111

12-
s.required_ruby_version = ">= 3.1.0"
12+
s.required_ruby_version = ">= 3.2.0"
1313

1414
s.license = "MIT"
1515

actionmailbox/actionmailbox.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
99
s.summary = "Inbound email handling framework."
1010
s.description = "Receive and process incoming emails in Rails applications."
1111

12-
s.required_ruby_version = ">= 3.1.0"
12+
s.required_ruby_version = ">= 3.2.0"
1313

1414
s.license = "MIT"
1515

actionmailer/actionmailer.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
99
s.summary = "Email composition and delivery framework (part of Rails)."
1010
s.description = "Email on Rails. Compose, deliver, and test emails using the familiar controller/view pattern. First-class support for multipart email and attachments."
1111

12-
s.required_ruby_version = ">= 3.1.0"
12+
s.required_ruby_version = ">= 3.2.0"
1313

1414
s.license = "MIT"
1515

actionpack/actionpack.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
99
s.summary = "Web-flow and rendering framework putting the VC in MVC (part of Rails)."
1010
s.description = "Web apps on Rails. Simple, battle-tested conventions for building and testing MVC web applications. Works with any Rack-compatible server."
1111

12-
s.required_ruby_version = ">= 3.1.0"
12+
s.required_ruby_version = ">= 3.2.0"
1313

1414
s.license = "MIT"
1515

actiontext/actiontext.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
99
s.summary = "Rich text framework."
1010
s.description = "Edit and display rich text in Rails applications."
1111

12-
s.required_ruby_version = ">= 3.1.0"
12+
s.required_ruby_version = ">= 3.2.0"
1313

1414
s.license = "MIT"
1515

actionview/actionview.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
99
s.summary = "Rendering framework putting the V in MVC (part of Rails)."
1010
s.description = "Simple, battle-tested conventions and helpers for building web pages."
1111

12-
s.required_ruby_version = ">= 3.1.0"
12+
s.required_ruby_version = ">= 3.2.0"
1313

1414
s.license = "MIT"
1515

actionview/test/template/render_test.rb

+31-33
Original file line numberDiff line numberDiff line change
@@ -208,45 +208,43 @@ def test_render_outside_path
208208
end
209209
end
210210

211-
if RUBY_VERSION >= "3.2"
212-
def test_render_runtime_error
213-
ex = assert_raises(ActionView::Template::Error) {
214-
@view.render(template: "test/runtime_error")
215-
}
216-
erb_btl = ex.backtrace_locations.first
217-
218-
# Get the spot information from ErrorHighlight
219-
translating_frame = ActionDispatch::ExceptionWrapper::SourceMapLocation.new(erb_btl, ex.template)
220-
translated_spot = translating_frame.spot(ex.cause)
221-
222-
assert_equal 6, translated_spot[:first_column]
223-
end
211+
def test_render_runtime_error
212+
ex = assert_raises(ActionView::Template::Error) {
213+
@view.render(template: "test/runtime_error")
214+
}
215+
erb_btl = ex.backtrace_locations.first
224216

225-
def test_render_location_conditional_append
226-
ex = assert_raises(ActionView::Template::Error) {
227-
@view.render(template: "test/unparseable_runtime_error")
228-
}
229-
erb_btl = ex.backtrace_locations.first
217+
# Get the spot information from ErrorHighlight
218+
translating_frame = ActionDispatch::ExceptionWrapper::SourceMapLocation.new(erb_btl, ex.template)
219+
translated_spot = translating_frame.spot(ex.cause)
230220

231-
# Get the spot information from ErrorHighlight
232-
translating_frame = ActionDispatch::ExceptionWrapper::SourceMapLocation.new(erb_btl, ex.template)
233-
translated_spot = translating_frame.spot(ex.cause)
221+
assert_equal 6, translated_spot[:first_column]
222+
end
234223

235-
assert_equal 8, translated_spot[:first_column]
236-
end
224+
def test_render_location_conditional_append
225+
ex = assert_raises(ActionView::Template::Error) {
226+
@view.render(template: "test/unparseable_runtime_error")
227+
}
228+
erb_btl = ex.backtrace_locations.first
237229

238-
def test_render_location_conditional_append_2
239-
ex = assert_raises(ActionView::Template::Error) {
240-
@view.render(template: "test/unparseable_runtime_error_2")
241-
}
242-
erb_btl = ex.backtrace_locations.first
230+
# Get the spot information from ErrorHighlight
231+
translating_frame = ActionDispatch::ExceptionWrapper::SourceMapLocation.new(erb_btl, ex.template)
232+
translated_spot = translating_frame.spot(ex.cause)
243233

244-
# Get the spot information from ErrorHighlight
245-
translating_frame = ActionDispatch::ExceptionWrapper::SourceMapLocation.new(erb_btl, ex.template)
246-
translated_spot = translating_frame.spot(ex.cause)
234+
assert_equal 8, translated_spot[:first_column]
235+
end
247236

248-
assert_instance_of Integer, translated_spot[:first_column]
249-
end
237+
def test_render_location_conditional_append_2
238+
ex = assert_raises(ActionView::Template::Error) {
239+
@view.render(template: "test/unparseable_runtime_error_2")
240+
}
241+
erb_btl = ex.backtrace_locations.first
242+
243+
# Get the spot information from ErrorHighlight
244+
translating_frame = ActionDispatch::ExceptionWrapper::SourceMapLocation.new(erb_btl, ex.template)
245+
translated_spot = translating_frame.spot(ex.cause)
246+
247+
assert_instance_of Integer, translated_spot[:first_column]
250248
end
251249

252250
def test_render_partial

activejob/activejob.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
99
s.summary = "Job framework with pluggable queues."
1010
s.description = "Declare job classes that can be run by a variety of queuing backends."
1111

12-
s.required_ruby_version = ">= 3.1.0"
12+
s.required_ruby_version = ">= 3.2.0"
1313

1414
s.license = "MIT"
1515

activemodel/activemodel.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
99
s.summary = "A toolkit for building modeling frameworks (part of Rails)."
1010
s.description = "A toolkit for building modeling frameworks like Active Record. Rich support for attributes, callbacks, validations, serialization, internationalization, and testing."
1111

12-
s.required_ruby_version = ">= 3.1.0"
12+
s.required_ruby_version = ">= 3.2.0"
1313

1414
s.license = "MIT"
1515

activemodel/lib/active_model/type/helpers/time_value.rb

+20-44
Original file line numberDiff line numberDiff line change
@@ -69,56 +69,32 @@ def new_time(year, mon, mday, hour, min, sec, microsec, offset = nil)
6969
\z
7070
/x
7171

72-
if RUBY_VERSION >= "3.2"
73-
if Time.new(2000, 1, 1, 0, 0, 0, "-00:00").yday != 1 # Early 3.2.x had a bug
74-
# BUG: Wrapping the Time object with Time.at because Time.new with `in:` in Ruby 3.2.0
75-
# used to return an invalid Time object
76-
# see: https://bugs.ruby-lang.org/issues/19292
77-
def fast_string_to_time(string)
78-
return unless string.include?("-") # Time.new("1234") # => 1234-01-01 00:00:00
79-
80-
if is_utc?
81-
::Time.at(::Time.new(string, in: "UTC"))
82-
else
83-
::Time.new(string)
84-
end
85-
rescue ArgumentError
86-
nil
87-
end
88-
else
89-
def fast_string_to_time(string)
90-
return unless string.include?("-") # Time.new("1234") # => 1234-01-01 00:00:00
91-
92-
if is_utc?
93-
::Time.new(string, in: "UTC")
94-
else
95-
::Time.new(string)
96-
end
97-
rescue ArgumentError
98-
nil
72+
if Time.new(2000, 1, 1, 0, 0, 0, "-00:00").yday != 1 # Early 3.2.x had a bug
73+
# BUG: Wrapping the Time object with Time.at because Time.new with `in:` in Ruby 3.2.0
74+
# used to return an invalid Time object
75+
# see: https://bugs.ruby-lang.org/issues/19292
76+
def fast_string_to_time(string)
77+
return unless string.include?("-") # Time.new("1234") # => 1234-01-01 00:00:00
78+
79+
if is_utc?
80+
::Time.at(::Time.new(string, in: "UTC"))
81+
else
82+
::Time.new(string)
9983
end
84+
rescue ArgumentError
85+
nil
10086
end
10187
else
10288
def fast_string_to_time(string)
103-
return unless ISO_DATETIME =~ string
89+
return unless string.include?("-") # Time.new("1234") # => 1234-01-01 00:00:00
10490

105-
usec = $7.to_i
106-
usec_len = $7&.length
107-
if usec_len&.< 6
108-
usec *= 10**(6 - usec_len)
91+
if is_utc?
92+
::Time.new(string, in: "UTC")
93+
else
94+
::Time.new(string)
10995
end
110-
111-
if $8
112-
offset = \
113-
if $8 == "Z"
114-
0
115-
else
116-
offset_h, offset_m = $8.to_i, $9.to_i
117-
offset_h.to_i * 3600 + (offset_h.negative? ? -1 : 1) * offset_m * 60
118-
end
119-
end
120-
121-
new_time($1.to_i, $2.to_i, $3.to_i, $4.to_i, $5.to_i, $6.to_i, usec, offset)
96+
rescue ArgumentError
97+
nil
12298
end
12399
end
124100
end

activerecord/activerecord.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
99
s.summary = "Object-relational mapper framework (part of Rails)."
1010
s.description = "Databases on Rails. Build a persistent domain model by mapping database tables to Ruby classes. Strong conventions for associations, validations, aggregations, migrations, and testing come baked-in."
1111

12-
s.required_ruby_version = ">= 3.1.0"
12+
s.required_ruby_version = ">= 3.2.0"
1313

1414
s.license = "MIT"
1515

activestorage/activestorage.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
99
s.summary = "Local and cloud file storage framework."
1010
s.description = "Attach cloud and local files in Rails applications."
1111

12-
s.required_ruby_version = ">= 3.1.0"
12+
s.required_ruby_version = ">= 3.2.0"
1313

1414
s.license = "MIT"
1515

activesupport/activesupport.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
99
s.summary = "A toolkit of support libraries and Ruby core extensions extracted from the Rails framework."
1010
s.description = "A toolkit of support libraries and Ruby core extensions extracted from the Rails framework. Rich support for multibyte strings, internationalization, time zones, and testing."
1111

12-
s.required_ruby_version = ">= 3.1.0"
12+
s.required_ruby_version = ">= 3.2.0"
1313

1414
s.license = "MIT"
1515

activesupport/lib/active_support/core_ext/object/json.rb

+3-5
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,9 @@ def as_json(options = nil) # :nodoc:
6565
end
6666
end
6767

68-
if RUBY_VERSION >= "3.2"
69-
class Data # :nodoc:
70-
def as_json(options = nil)
71-
to_h.as_json(options)
72-
end
68+
class Data # :nodoc:
69+
def as_json(options = nil)
70+
to_h.as_json(options)
7371
end
7472
end
7573

activesupport/test/core_ext/enumerable_test.rb

-2
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,5 @@ def test_doesnt_bust_constant_cache
412412
private
413413
def constant_cache_invalidations
414414
RubyVM.stat(:constant_cache_invalidations)
415-
rescue ArgumentError
416-
RubyVM.stat(:global_constant_state) # RUBY_VERSION < "3.2"
417415
end
418416
end

activesupport/test/executor_test.rb

-29
Original file line numberDiff line numberDiff line change
@@ -225,35 +225,6 @@ def test_hook_insertion_order
225225
assert_equal [:state_a, :state_b, :state_d, :state_c], supplied_state
226226
end
227227

228-
if RUBY_VERSION < "3.2"
229-
def test_class_serial_is_unaffected
230-
skip if !defined?(RubyVM) || !RubyVM.stat.has_key?(:class_serial)
231-
232-
hook = Class.new do
233-
define_method(:run) do
234-
nil
235-
end
236-
237-
define_method(:complete) do |state|
238-
nil
239-
end
240-
end.new
241-
242-
executor.register_hook(hook)
243-
244-
# Warm-up to trigger any pending autoloads
245-
executor.wrap { }
246-
247-
before = RubyVM.stat(:class_serial)
248-
executor.wrap { }
249-
executor.wrap { }
250-
executor.wrap { }
251-
after = RubyVM.stat(:class_serial)
252-
253-
assert_equal before, after
254-
end
255-
end
256-
257228
def test_separate_classes_can_wrap
258229
other_executor = Class.new(ActiveSupport::Executor)
259230

activesupport/test/json/encoding_test.rb

+5-7
Original file line numberDiff line numberDiff line change
@@ -346,15 +346,13 @@ def test_struct_encoding
346346
ActiveSupport::JSON.decode(json_string_and_date))
347347
end
348348

349-
if RUBY_VERSION >= "3.2"
350-
def test_data_encoding
351-
data = Data.define(:name, :email).new("test", "[email protected]")
349+
def test_data_encoding
350+
data = Data.define(:name, :email).new("test", "[email protected]")
352351

353-
assert_nothing_raised { data.to_json }
352+
assert_nothing_raised { data.to_json }
354353

355-
assert_equal({ "name" => "test", "email" => "[email protected]" },
356-
ActiveSupport::JSON.decode(data.to_json))
357-
end
354+
assert_equal({ "name" => "test", "email" => "[email protected]" },
355+
ActiveSupport::JSON.decode(data.to_json))
358356
end
359357

360358
def test_nil_true_and_false_represented_as_themselves

activesupport/test/time_travel_test.rb

+6-16
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ def test_time_helper_travel
3535
assert_equal expected_time.to_datetime.to_fs(:db), DateTime.now.to_fs(:db)
3636

3737
assert_equal expected_time.to_fs(:db), Time.new.to_fs(:db)
38-
if RUBY_VERSION >= "3.2"
39-
assert_not_equal expected_time.to_fs(:db), Time.new(precision: 3).to_fs(:db)
40-
end
38+
assert_not_equal expected_time.to_fs(:db), Time.new(precision: 3).to_fs(:db)
4139
ensure
4240
travel_back
4341
end
@@ -53,18 +51,14 @@ def test_time_helper_travel_with_block
5351
assert_equal expected_time.to_datetime.to_fs(:db), DateTime.now.to_fs(:db)
5452

5553
assert_equal expected_time.to_fs(:db), Time.new.to_fs(:db)
56-
if RUBY_VERSION >= "3.2"
57-
assert_not_equal expected_time.to_fs(:db), Time.new(precision: 3).to_fs(:db)
58-
assert_equal Time.new("2000-12-31 23:59:59.567"), Time.new("2000-12-31 23:59:59.56789", precision: 3)
59-
end
54+
assert_not_equal expected_time.to_fs(:db), Time.new(precision: 3).to_fs(:db)
55+
assert_equal Time.new("2000-12-31 23:59:59.567"), Time.new("2000-12-31 23:59:59.56789", precision: 3)
6056
end
6157

6258
assert_not_equal expected_time.to_fs(:db), Time.now.to_fs(:db)
6359
assert_not_equal expected_time.to_date, Date.today
6460
assert_not_equal expected_time.to_datetime.to_fs(:db), DateTime.now.to_fs(:db)
65-
if RUBY_VERSION >= "3.2"
66-
assert_equal Time.new("2000-12-31 23:59:59.567"), Time.new("2000-12-31 23:59:59.56789", precision: 3)
67-
end
61+
assert_equal Time.new("2000-12-31 23:59:59.567"), Time.new("2000-12-31 23:59:59.56789", precision: 3)
6862
end
6963
end
7064

@@ -76,9 +70,7 @@ def test_time_helper_travel_to
7670
assert_equal expected_time, Time.now
7771
assert_equal expected_time, Time.new
7872
assert_not_equal expected_time, Time.new(2004, 11, 25)
79-
if RUBY_VERSION >= "3.2"
80-
assert_not_equal expected_time, Time.new(precision: 3)
81-
end
73+
assert_not_equal expected_time, Time.new(precision: 3)
8274
assert_equal Date.new(2004, 11, 24), Date.today
8375
assert_equal expected_time.to_datetime, DateTime.now
8476
ensure
@@ -93,9 +85,7 @@ def test_time_helper_travel_to_with_block
9385
travel_to expected_time do
9486
assert_equal expected_time, Time.now
9587
assert_equal expected_time, Time.new
96-
if RUBY_VERSION >= "3.2"
97-
assert_not_equal expected_time, Time.new(precision: 3)
98-
end
88+
assert_not_equal expected_time, Time.new(precision: 3)
9989
assert_not_equal expected_time, Time.new(2004, 11, 25)
10090
assert_equal Date.new(2004, 11, 24), Date.today
10191
assert_equal expected_time.to_datetime, DateTime.now

0 commit comments

Comments
 (0)