Skip to content

Fix Devise 5 compatibility and add GitHub Actions CI#164

Open
tim-gq wants to merge 2 commits into
oivoodoo:masterfrom
GreatQuestion:fix/devise-5-test-compatibility
Open

Fix Devise 5 compatibility and add GitHub Actions CI#164
tim-gq wants to merge 2 commits into
oivoodoo:masterfrom
GreatQuestion:fix/devise-5-test-compatibility

Conversation

@tim-gq

@tim-gq tim-gq commented Mar 23, 2026

Copy link
Copy Markdown

Summary

This PR fixes test compatibility with Devise 5 and adds a GitHub Actions CI workflow to test against both Devise 4 and Devise 5.

Changes

Fix deprecated sign_in call in test helper (spec/support/authentication.rb)

Devise 5 removed the two-argument sign_in(scope, resource) form. The keyword argument form sign_in(resource, scope: :scope_name) works with both Devise 4 and Devise 5:

# Before (Devise 4 only)
sign_in(:admin, @admin_user)

# After (Devise 4 and 5)
sign_in(@admin_user, scope: :admin)

Add GitHub Actions CI workflow (.github/workflows/ci.yml)

  • Runs on push to master/main and on pull requests
  • Tests against a matrix of Ruby 3.3/3.4 and Devise 4/5
  • Runs both bundle exec rspec and bundle exec cucumber
  • Uses DEVISE_VERSION env var to control Devise version pinning

Update Gemfile for version matrix support

Added a conditional block that respects the DEVISE_VERSION environment variable to pin devise ~> 4.9 or devise ~> 5.0. When unset, the gemspec's devise >= 4.7.0 constraint applies as before.

Fix dummy app for modern Rails compatibility

  • spec/dummy/db/schema.rb: Use ActiveRecord::Schema[7.2].define(...) instead of the deprecated ActiveRecord::Schema.define(...) format (required by Rails 7.2+)
  • spec/dummy/config/environments/test.rb: Remove config.whiny_nils (removed in Rails 4) and change show_exceptions = false to show_exceptions = :none (required since Rails 7.1)

tim-gq and others added 2 commits March 23, 2026 15:01
Devise 5 removed the two-argument `sign_in(scope, resource)` form.
Use the keyword argument form `sign_in(resource, scope: :scope_name)`
which is compatible with both Devise 4 and Devise 5.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add .github/workflows/ci.yml that runs RSpec and Cucumber against
  both Devise 4 and Devise 5 on Ruby 3.3 and 3.4
- Update Gemfile to respect DEVISE_VERSION env var for pinning the
  Devise version during CI
- Fix spec/dummy/db/schema.rb to use ActiveRecord::Schema[7.2] format
  required by modern Rails
- Fix spec/dummy/config/environments/test.rb: remove whiny_nils
  (removed in Rails 4) and use show_exceptions = :none (required
  since Rails 7.1)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@tim-gq tim-gq changed the title Fix test helper for Devise 5 compatibility Fix Devise 5 compatibility and add GitHub Actions CI Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant