Skip to content

Commit

Permalink
feat: Add support for Rails 7.1 (#1573)
Browse files Browse the repository at this point in the history
* Add Rails 7.1 to appraisals

* fix: Adjust validate options when managing columns and tables in migration

This commit adjusts the way we manage columns and tables in migrations
to account for the changes in Rails 7.1.0, it was introduced in this
Rails version a validation around the options passed to tables and
columns in migrations, so we need to adjust our code to skip this
validation.

This PR introduced this new validation on the migrations:
rails/rails#46178

* Refine `ActiveRecord::SerializeMatcher` for Rails 7.1 compatibility

This commit refines the `ActiveRecord::SerializeMatcher` to
accommodate changes in the public API introduced in Rails 7.1.
The `serialize` method's API has been updated, necessitating
adjustments to our matcher specs to align with the new API.

While this PR addresses the immediate need for compatibility,
there is potential for further enhancements and refinements in
the matcher's implementation to bring it in line with the revised
public API. However, such improvements will be explored in a future PR.

For reference, the changes in the public API can be found in the following PR: rails/rails#47463

This commit adjusts the `ActiveRecord::SerializeMatcher` the public
API for the `serialize` method has changed on Rails 7.1, so we
had to

* feat: Upadte workflow matrix

* fix: Adjust comparison between hash and `ActionController::Parameters`

The behavior of the comparison between hash and a
`ActionController::Parameters` was changed and now will be deprecated.

Check this Rails PR for more context
rails/rails#44826.

* fix: Adjust usage of `has_secure_token` without a token attr

The behaviour of this method was changed in Rails 7.1, and now
it'll search for a `token` attr in the initialization of the record
instead of the creation. To stay with the same behaviour as before
it's necessary to pass a new argument `on: : create` to the method.

* fix: Adjust specs for primary_key check

* fix: Test updating error_highlight gem

* fix: Add default Rails tables to acceptance spec

This commit fixes the problem of not finding the tables
when running the specs in eager load mode, this was introduced
by Rails 7.1.

Load the model schema when running test in eager load
context rails/rails#49470
  • Loading branch information
matsales28 authored Nov 17, 2023
1 parent 0dc6c6d commit 7e069cf
Show file tree
Hide file tree
Showing 12 changed files with 561 additions and 44 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ jobs:
- 3.1.4
- 3.0.6
appraisal:
- rails_7_1
- rails_7_0
- rails_6_1
adapter:
- sqlite3
- postgresql
exclude:
- { ruby: 3.2.2, appraisal: rails_6_1 }
- { ruby: 3.1.4, appraisal: rails_5_2 }
- { ruby: 3.0.6, appraisal: rails_5_2 }
- { ruby: 3.0.6, appraisal: rails_7_0 }
- { ruby: 3.0.6, appraisal: rails_7_1 }
env:
DATABASE_ADAPTER: ${{ matrix.adapter }}
BUNDLE_GEMFILE: gemfiles/${{ matrix.appraisal }}.gemfile
Expand Down
28 changes: 28 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,31 @@ appraise 'rails_7_0' do
gem 'sqlite3', '~> 1.4'
gem 'pg', '~> 1.1'
end

appraise 'rails_7_1' do
instance_eval(&shared_spring_dependencies)
instance_eval(&controller_test_dependency)

gem 'rails', '7.1.0'
gem 'sprockets-rails'
gem 'puma', '~> 6.0'
gem 'importmap-rails'
gem 'turbo-rails'
gem 'stimulus-rails'
gem 'jbuilder'
gem 'bootsnap', require: false
gem 'capybara'
gem 'selenium-webdriver'
gem 'webdrivers'

# test dependencies
gem 'rspec-rails', '~> 6.0'
gem 'shoulda-context', '~> 2.0.0'

# other dependencies
gem 'bcrypt', '~> 3.1.7'

# Database adapters
gem 'sqlite3', '~> 1.4'
gem 'pg', '~> 1.1'
end
42 changes: 42 additions & 0 deletions gemfiles/rails_7_1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "appraisal", "2.4.0"
gem "bundler", "~> 2.0"
gem "pry"
gem "pry-byebug"
gem "rake", "13.0.1"
gem "rspec", "~> 3.9"
gem "rubocop", require: false
gem "rubocop-packaging", require: false
gem "rubocop-rails", require: false
gem "warnings_logger"
gem "zeus", require: false
gem "fssm"
gem "redcarpet"
gem "rouge"
gem "yard"
gem "spring"
gem "spring-watcher-listen", "~> 2.0.0"
gem "rails-controller-testing", ">= 1.0.1"
gem "rails", "7.1.0"
gem "sprockets-rails"
gem "puma", "~> 6.0"
gem "importmap-rails"
gem "turbo-rails"
gem "stimulus-rails"
gem "jbuilder"
gem "bootsnap", require: false
gem "capybara"
gem "selenium-webdriver"
gem "webdrivers"
gem "rspec-rails", "~> 6.0"
gem "shoulda-context", "~> 2.0.0"
gem "bcrypt", "~> 3.1.7"
gem "sqlite3", "~> 1.4"
gem "pg", "~> 1.1"

if RUBY_VERSION >= "3.1" && RUBY_VERSION < "3.2"
gem "error_highlight", ">= 0.4.0", platforms: [:ruby]
end
Loading

0 comments on commit 7e069cf

Please sign in to comment.