Skip to content

Commit a81ef6e

Browse files
authored
Merge pull request #661 from rails/rm-test-7.0-drop-ruby-2.6
Drop support to Ruby < 2.7 and Rails < 6.0
2 parents 98a7631 + a766ced commit a81ef6e

11 files changed

+27
-34
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,7 @@ jobs:
77
fail-fast: false
88
matrix:
99
ruby: [ '2.7', '3.0.2', 'head' ]
10-
rails: [ '6.0', '6.1', 'edge' ]
11-
include:
12-
- ruby: '2.6'
13-
rails: '5.2'
14-
- ruby: '2.6'
15-
rails: '6.0'
16-
- ruby: '2.6'
17-
rails: '6.1'
10+
rails: [ '6.0', '6.1', '7.0', 'edge' ]
1811

1912
env:
2013
RAILS_VERSION: ${{ matrix.rails }}

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
* Stop requiring `set` before bundler can select the proper version. This could result in
44
`already defined constant` warnings during boot (#659).
5+
* Require Ruby 2.7.
6+
* Require Rails 6.0.
57

68
## 3.1.1
79

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ acceptance tests again, which will generate a new app.
3030
You can set the `RAILS_VERSION` environment variable:
3131

3232
```
33-
$ RAILS_VERSION="~> 3.2.0" rake test:acceptance
33+
$ RAILS_VERSION="6.1" rake test:acceptance
3434
```
3535

3636
The apps in `test/apps` will be named based on the rails version, and the

Gemfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ gemspec
55

66
if ENV["RAILS_VERSION"] == "edge"
77
gem "activesupport", github: "rails/rails", branch: "main"
8+
elsif ENV['RAILS_VERSION'] == "7.0"
9+
gem "activesupport", ">= 7.0.0.alpha"
10+
">= 7.0.0.alpha"
811
elsif ENV["RAILS_VERSION"]
9-
gem "activesupport", ENV["RAILS_VERSION"]
12+
gem "activesupport", "~> #{ENV["RAILS_VERSION"]}.0"
1013
end

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ boot it every time you run a test, rake task or migration.
1616

1717
## Compatibility
1818

19-
* Ruby versions: MRI 2.5, MRI 2.6
20-
* Rails versions: 5.2, 6.0 (Spring is installed by default when you do
21-
`rails new` to generate your application)
19+
* Ruby versions: MRI 2.7, MRI 3.0, MRI 3.1
20+
* Rails versions: 6.0, 6.1, 7.0
2221

2322
Spring makes extensive use of `Process.fork`, so won't be able to
2423
provide a speed up on platforms which don't support forking (Windows, JRuby).

lib/spring/application.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ def preload
9292

9393
require Spring.application_root_path.join("config", "application")
9494

95-
unless Rails.respond_to?(:gem_version) && Rails.gem_version >= Gem::Version.new('5.2.0')
96-
raise "Spring only supports Rails >= 5.2.0"
95+
unless Rails.respond_to?(:gem_version) && Rails.gem_version >= Gem::Version.new('6.0.0')
96+
raise "Spring only supports Rails >= 6.0.0"
9797
end
9898

9999
Rails::Application.initializer :ensure_reloading_is_enabled, group: :all do

lib/spring/application_manager.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def stop
9393
def start_child(preload = false)
9494
@child, child_socket = UNIXSocket.pair
9595

96-
Bundler.with_original_env do
96+
Bundler.with_unbundled_env do
9797
bundler_dir = File.expand_path("../..", $LOADED_FEATURES.grep(/bundler\/setup\.rb$/).first)
9898
@pid = Process.spawn(
9999
{

spring.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
1313
gem.files = Dir["LICENSE.txt", "README.md", "lib/**/*", "bin/*"]
1414
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
1515

16-
gem.required_ruby_version = ">= 2.5.0"
16+
gem.required_ruby_version = ">= 2.7.0"
1717

1818
gem.add_development_dependency 'rake'
1919
gem.add_development_dependency 'bump'

test/support/acceptance_test.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ class AcceptanceTest < ActiveSupport::TestCase
1212

1313
def rails_version
1414
if ENV['RAILS_VERSION'] == "edge"
15-
"7.0.0.alpha"
15+
"7.1.0.alpha"
16+
elsif ENV['RAILS_VERSION'] == "7.0"
17+
">= 7.0.0.alpha"
1618
else
17-
'~> 6.0.0'
19+
"~> #{ENV['RAILS_VERSION'] || "6.1"}.0"
1820
end
1921
end
2022

@@ -157,7 +159,7 @@ def without_gem(name)
157159
end
158160

159161
test "code changes in pre-referenced app files are picked up" do
160-
File.write(app.path("config/initializers/load_posts_controller.rb"), "PostsController\n")
162+
File.write(app.path("config/initializers/load_posts_controller.rb"), "Rails.application.config.to_prepare { PostsController }\n")
161163

162164
assert_speedup do
163165
assert_success app.spring_test_command, stdout: "0 failures"
@@ -271,6 +273,7 @@ def exec_name
271273
test "binstub when spring gem is missing" do
272274
without_gem "spring-#{Spring::VERSION}" do
273275
File.write(app.gemfile, app.gemfile.read.gsub(/gem 'spring.*/, ""))
276+
app.run! "bundle install", timeout: 300
274277
assert_success "bin/rake -T", stdout: "rake db:migrate"
275278
end
276279
end
@@ -518,7 +521,8 @@ def exec_name
518521
test "changing the Gemfile works" do
519522
assert_success %(bin/rails runner 'require "sqlite3"')
520523

521-
File.write(app.gemfile, app.gemfile.read.gsub(%{gem 'sqlite3'}, %{# gem 'sqlite3'}))
524+
File.write(app.gemfile, app.gemfile.read.gsub(%r{gem ['"]sqlite3['"]}, %{# gem "sqlite3"}))
525+
puts app.gemfile.read
522526
app.await_reload
523527

524528
assert_failure %(bin/rails runner 'require "sqlite3"'), stderr: "sqlite3"
@@ -530,7 +534,7 @@ def exec_name
530534

531535
assert_success %(bin/rails runner 'require "sqlite3"')
532536

533-
File.write(app.gems_rb, app.gems_rb.read.sub(%{gem 'sqlite3'}, %{# gem 'sqlite3'}))
537+
File.write(app.gems_rb, app.gems_rb.read.gsub(%r{gem ['"]sqlite3['"]}, %{# gem "sqlite3"}))
534538
app.await_reload
535539

536540
assert_failure %(bin/rails runner 'require "sqlite3"'), stderr: "sqlite3"
@@ -540,7 +544,7 @@ def exec_name
540544
File.write(app.path("script.rb"), <<-RUBY.strip_heredoc)
541545
gemfile = Rails.root.join("Gemfile")
542546
File.write(gemfile, "\#{gemfile.read}gem 'text'\\n")
543-
Bundler.with_clean_env do
547+
Bundler.with_unbundled_env do
544548
system(#{app.env.inspect}, "bundle install")
545549
end
546550
output = `\#{Rails.root.join('bin/rails')} runner 'require "text"; puts "done";'`
@@ -557,7 +561,7 @@ def exec_name
557561
File.write(app.path("script.rb"), <<-RUBY.strip_heredoc)
558562
gemfile = Rails.root.join("gems.rb")
559563
File.write(gemfile, "\#{gemfile.read}gem 'text'\\n")
560-
Bundler.with_clean_env do
564+
Bundler.with_unbundled_env do
561565
system(#{app.env.inspect}, "bundle install")
562566
end
563567
output = `\#{Rails.root.join('bin/rails')} runner 'require "text"; puts "done";'`

test/support/application.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def spring_client_config
111111
def run(command, opts = {})
112112
start_time = Time.now
113113

114-
Bundler.with_original_env do
114+
Bundler.with_unbundled_env do
115115
Process.spawn(
116116
env.merge(opts[:env] || {}),
117117
command.to_s,

test/support/application_generator.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def system(command)
3131
end
3232

3333
def generate
34-
Bundler.with_original_env { generate_files }
34+
Bundler.with_unbundled_env { generate_files }
3535
install_spring
3636
generate_scaffold
3737
end
@@ -60,17 +60,9 @@ def generate_files
6060
c.sub!("https://rubygems.org", "http://rubygems.org")
6161
c.gsub!(/(gem '(byebug|web-console|sdoc|jbuilder)')/, "# \\1")
6262

63-
if @version.to_s < '5.2'
64-
c.gsub!(/(gem 'sqlite3')/, "# \\1")
65-
end
66-
6763
c
6864
end
6965

70-
if @version.to_s < '5.2'
71-
append_to_file(application.gemfile, "gem 'sqlite3', '< 1.4'")
72-
end
73-
7466
rewrite_file(application.path("config/environments/test.rb")) do |c|
7567
c.sub!(/config\.cache_classes\s*=\s*true/, "config.cache_classes = false")
7668
c

0 commit comments

Comments
 (0)