Skip to content

Commit

Permalink
Merge pull request #661 from rails/rm-test-7.0-drop-ruby-2.6
Browse files Browse the repository at this point in the history
Drop support to Ruby < 2.7 and Rails < 6.0
  • Loading branch information
rafaelfranca committed Dec 10, 2021
2 parents 98a7631 + a766ced commit a81ef6e
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 34 deletions.
9 changes: 1 addition & 8 deletions .github/workflows/ci.yml
Expand Up @@ -7,14 +7,7 @@ jobs:
fail-fast: false
matrix:
ruby: [ '2.7', '3.0.2', 'head' ]
rails: [ '6.0', '6.1', 'edge' ]
include:
- ruby: '2.6'
rails: '5.2'
- ruby: '2.6'
rails: '6.0'
- ruby: '2.6'
rails: '6.1'
rails: [ '6.0', '6.1', '7.0', 'edge' ]

env:
RAILS_VERSION: ${{ matrix.rails }}
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,8 @@

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

## 3.1.1

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Expand Up @@ -30,7 +30,7 @@ acceptance tests again, which will generate a new app.
You can set the `RAILS_VERSION` environment variable:

```
$ RAILS_VERSION="~> 3.2.0" rake test:acceptance
$ RAILS_VERSION="6.1" rake test:acceptance
```

The apps in `test/apps` will be named based on the rails version, and the
Expand Down
5 changes: 4 additions & 1 deletion Gemfile
Expand Up @@ -5,6 +5,9 @@ gemspec

if ENV["RAILS_VERSION"] == "edge"
gem "activesupport", github: "rails/rails", branch: "main"
elsif ENV['RAILS_VERSION'] == "7.0"
gem "activesupport", ">= 7.0.0.alpha"
">= 7.0.0.alpha"
elsif ENV["RAILS_VERSION"]
gem "activesupport", ENV["RAILS_VERSION"]
gem "activesupport", "~> #{ENV["RAILS_VERSION"]}.0"
end
5 changes: 2 additions & 3 deletions README.md
Expand Up @@ -16,9 +16,8 @@ boot it every time you run a test, rake task or migration.

## Compatibility

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

Spring makes extensive use of `Process.fork`, so won't be able to
provide a speed up on platforms which don't support forking (Windows, JRuby).
Expand Down
4 changes: 2 additions & 2 deletions lib/spring/application.rb
Expand Up @@ -92,8 +92,8 @@ def preload

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

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

Rails::Application.initializer :ensure_reloading_is_enabled, group: :all do
Expand Down
2 changes: 1 addition & 1 deletion lib/spring/application_manager.rb
Expand Up @@ -93,7 +93,7 @@ def stop
def start_child(preload = false)
@child, child_socket = UNIXSocket.pair

Bundler.with_original_env do
Bundler.with_unbundled_env do
bundler_dir = File.expand_path("../..", $LOADED_FEATURES.grep(/bundler\/setup\.rb$/).first)
@pid = Process.spawn(
{
Expand Down
2 changes: 1 addition & 1 deletion spring.gemspec
Expand Up @@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
gem.files = Dir["LICENSE.txt", "README.md", "lib/**/*", "bin/*"]
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }

gem.required_ruby_version = ">= 2.5.0"
gem.required_ruby_version = ">= 2.7.0"

gem.add_development_dependency 'rake'
gem.add_development_dependency 'bump'
Expand Down
18 changes: 11 additions & 7 deletions test/support/acceptance_test.rb
Expand Up @@ -12,9 +12,11 @@ class AcceptanceTest < ActiveSupport::TestCase

def rails_version
if ENV['RAILS_VERSION'] == "edge"
"7.0.0.alpha"
"7.1.0.alpha"
elsif ENV['RAILS_VERSION'] == "7.0"
">= 7.0.0.alpha"
else
'~> 6.0.0'
"~> #{ENV['RAILS_VERSION'] || "6.1"}.0"
end
end

Expand Down Expand Up @@ -157,7 +159,7 @@ def without_gem(name)
end

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

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

File.write(app.gemfile, app.gemfile.read.gsub(%{gem 'sqlite3'}, %{# gem 'sqlite3'}))
File.write(app.gemfile, app.gemfile.read.gsub(%r{gem ['"]sqlite3['"]}, %{# gem "sqlite3"}))
puts app.gemfile.read
app.await_reload

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

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

File.write(app.gems_rb, app.gems_rb.read.sub(%{gem 'sqlite3'}, %{# gem 'sqlite3'}))
File.write(app.gems_rb, app.gems_rb.read.gsub(%r{gem ['"]sqlite3['"]}, %{# gem "sqlite3"}))
app.await_reload

assert_failure %(bin/rails runner 'require "sqlite3"'), stderr: "sqlite3"
Expand All @@ -540,7 +544,7 @@ def exec_name
File.write(app.path("script.rb"), <<-RUBY.strip_heredoc)
gemfile = Rails.root.join("Gemfile")
File.write(gemfile, "\#{gemfile.read}gem 'text'\\n")
Bundler.with_clean_env do
Bundler.with_unbundled_env do
system(#{app.env.inspect}, "bundle install")
end
output = `\#{Rails.root.join('bin/rails')} runner 'require "text"; puts "done";'`
Expand All @@ -557,7 +561,7 @@ def exec_name
File.write(app.path("script.rb"), <<-RUBY.strip_heredoc)
gemfile = Rails.root.join("gems.rb")
File.write(gemfile, "\#{gemfile.read}gem 'text'\\n")
Bundler.with_clean_env do
Bundler.with_unbundled_env do
system(#{app.env.inspect}, "bundle install")
end
output = `\#{Rails.root.join('bin/rails')} runner 'require "text"; puts "done";'`
Expand Down
2 changes: 1 addition & 1 deletion test/support/application.rb
Expand Up @@ -111,7 +111,7 @@ def spring_client_config
def run(command, opts = {})
start_time = Time.now

Bundler.with_original_env do
Bundler.with_unbundled_env do
Process.spawn(
env.merge(opts[:env] || {}),
command.to_s,
Expand Down
10 changes: 1 addition & 9 deletions test/support/application_generator.rb
Expand Up @@ -31,7 +31,7 @@ def system(command)
end

def generate
Bundler.with_original_env { generate_files }
Bundler.with_unbundled_env { generate_files }
install_spring
generate_scaffold
end
Expand Down Expand Up @@ -60,17 +60,9 @@ def generate_files
c.sub!("https://rubygems.org", "http://rubygems.org")
c.gsub!(/(gem '(byebug|web-console|sdoc|jbuilder)')/, "# \\1")

if @version.to_s < '5.2'
c.gsub!(/(gem 'sqlite3')/, "# \\1")
end

c
end

if @version.to_s < '5.2'
append_to_file(application.gemfile, "gem 'sqlite3', '< 1.4'")
end

rewrite_file(application.path("config/environments/test.rb")) do |c|
c.sub!(/config\.cache_classes\s*=\s*true/, "config.cache_classes = false")
c
Expand Down

0 comments on commit a81ef6e

Please sign in to comment.