Skip to content

Commit

Permalink
Support Rails 7.1 (#8102)
Browse files Browse the repository at this point in the history
* run ci against rails 7.1

* change test_app name

* make test app generation work with rails 7.1 and older

* resolve ransack 'NoMethodError: undefined method '

* formtastic 'DEPRECATION WARNING: Calling silence on ActiveSupport::Deprecation is deprecated and will be removed from Rails'

* do not check redirect body anymore because rails 7.1 removed it

see rails/rails@c2e756a

* temporal: resolve cucumber-rails DEPRECATION WARNING: Setting action_dispatch.show_exceptions to false is deprecated. Set to :none instead

* enable reloading to be able to test 'class-reload in development'

* bump devise from 4.9.2 to 4.9.3

* Fix tabs_spec flaky tests by allow lazy load of transliteration rules

Run the following code prior this commit to see the error

```
rspec ./spec/unit/views/components/tabs_spec.rb:42 --seed 57923
```

The error:

```
Failure/Error: result = string.parameterize

       I18n received :t with unexpected arguments
         expected: (:tab_key)
              got: (:"i18n.transliterate.rule", {:default=>{}, :locale=>:en, :resolve=>false})
       Diff:
       @@ -1 +1 @@
       -[:tab_key]
       +[:"i18n.transliterate.rule", {:default=>{}, :locale=>:en, :resolve=>false}]

     # /home/matias/.rvm/gems/ruby-3.2.2/gems/i18n-1.14.1/lib/i18n/backend/transliterator.rb:13:in `transliterate'
     # /home/matias/.rvm/gems/ruby-3.2.2/gems/i18n-1.14.1/lib/i18n.rb:298:in `transliterate'
     # /home/matias/.rvm/gems/ruby-3.2.2/gems/activesupport-7.1.0/lib/active_support/inflector/transliterate.rb:84:in `transliterate'
     # /home/matias/.rvm/gems/ruby-3.2.2/gems/activesupport-7.1.0/lib/active_support/inflector/transliterate.rb:125:in `parameterize'
     # /home/matias/.rvm/gems/ruby-3.2.2/gems/activesupport-7.1.0/lib/active_support/core_ext/string/inflections.rb:216:in `parameterize'
     # ./lib/active_admin/views/components/tabs.rb:35:in `fragmentize'
     # ./lib/active_admin/views/components/tabs.rb:19:in `build_menu_item'
     # ./lib/active_admin/views/components/tabs.rb:9:in `tab'
```

The problem?

tab calls `parameterize` on the give title. That use `I18n.transliterate` under the hood which calls `I18n.t`.
We must consider that call in our stub.

Why is a flaky tests?

Because `I18n` uses an internal cache. Only the first call to `I18n.transliterate` calls `I18n.t`.

See

https://github.com/rails/rails/blob/v7.1.1/activesupport/lib/active_support/core_ext/string/inflections.rb#L216
https://github.com/rails/rails/blob/v7.1.1/activesupport/lib/active_support/inflector/transliterate.rb#L123
https://github.com/rails/rails/blob/v7.1.1/activesupport/lib/active_support/inflector/transliterate.rb#L64
https://github.com/ruby-i18n/i18n/blob/v1.14.1/lib/i18n/backend/transliterator.rb#L13

* require ransack 4.1

* Revert "require ransack 4.1"

This reverts commit 51f665e.

This would force users to drop ruby 2.7
  • Loading branch information
mgrunberg committed Oct 23, 2023
1 parent 1a06688 commit c17be6e
Show file tree
Hide file tree
Showing 9 changed files with 617 additions and 95 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,17 @@ jobs:
deps:
- rails_61
- rails_70
- rails_71
steps:
- uses: actions/checkout@v3
- name: Configure bundler (default)
run: |
echo "BUNDLE_GEMFILE=Gemfile" >> "$GITHUB_ENV"
if: matrix.deps == 'rails_70'
if: matrix.deps == 'rails_71'
- name: Configure bundler (alternative)
run: |
echo "BUNDLE_GEMFILE=gemfiles/${{ matrix.deps }}/Gemfile" >> "$GITHUB_ENV"
if: matrix.deps != 'rails_70'
if: matrix.deps != 'rails_71'
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
Expand Down
6 changes: 4 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ group :development, :test do
gem "draper"
gem "devise"

gem "rails", "~> 7.0.0"
gem "rails", "~> 7.1.0"

gem "sprockets-rails"
gem "sassc-rails"
gem "ransack", ">= 4.1.0"
gem "formtastic", ">= 5.0.0"
end

group :test do
Expand All @@ -23,7 +25,7 @@ group :test do

gem "simplecov", require: false # Test coverage generator. Go to /coverage/ after running tests
gem "simplecov-cobertura", require: false
gem "cucumber-rails", require: false
gem "cucumber-rails", require: false, github: "cucumber/cucumber-rails", branch: "main"
gem "cucumber"
gem "database_cleaner"
gem "launchy"
Expand Down
Loading

0 comments on commit c17be6e

Please sign in to comment.