Skip to content

Devise 5 and Rails 7 compatibility#5

Open
kennethkalmer wants to merge 5 commits intomainfrom
devise-5-support
Open

Devise 5 and Rails 7 compatibility#5
kennethkalmer wants to merge 5 commits intomainfrom
devise-5-support

Conversation

@kennethkalmer
Copy link

@kennethkalmer kennethkalmer commented Mar 18, 2026

Summary

Tightens the devise dependency to ~> 5.0 and fixes remaining incompatibilities, building on top of the Ruby 3 and Rails 8 work already merged in #3 and #4. Also adds GitHub Actions CI.

  • Tighten devise constraint from >= 4.8.0, < 6.0 to ~> 5.0
  • Remove config.secret_key from Devise initializer (removed in Devise 5)
  • Remove dead code: rails5?/rails5_or_newer? methods, ActionController::StrongParameters conditional, Rails 3 attr_accessible generator support
  • Simplify engine reloader: remove conditional, always use ActiveSupport::Reloader
  • Fix test infrastructure: upgrade mocha to 2.x with minitest integration, fix secret_tokensecret_key_base, fix test environment config, remove bson_ext, make integration tests self-contained
  • Add GitHub Actions CI: runs tests on push and PR against Ruby 3.3 and 3.4

Context

The ably/website repo is upgrading to Devise 5 (PR #8054). This fork already resolves to Devise 5.0.3 thanks to the broad >= 4.8.0, < 6.0 constraint, but the gemspec should explicitly require ~> 5.0 since Devise 4.x APIs (like sign_in bypass: true) are no longer supported.

Test plan

  • bundle install resolves with Devise 5.0.3 and Rails 8.1.2
  • bundle exec rake test — 35 tests, 0 errors, 0 failures on clean runs
  • Tests pass with random seed ordering
  • GitHub Actions CI passes on Ruby 3.3 and 3.4

🤖 Generated with Claude Code

@kennethkalmer kennethkalmer force-pushed the devise-5-support branch 2 times, most recently from b91c48b to 68873a5 Compare March 18, 2026 16:24
@kennethkalmer kennethkalmer self-assigned this Mar 18, 2026
kennethkalmer and others added 5 commits March 19, 2026 12:16
- Tighten devise dependency to ~> 5.0 (was >= 4.8.0, < 6.0)
- Remove dead rails5?/rails5_or_newer? methods and conditional
- Simplify engine reloader: always use ActiveSupport::Reloader
- Remove Devise config.secret_key (removed in Devise 5)
- Remove dead StrongParameters conditional and Rails 3 generator code
- Fix secret_token → secret_key_base for Rails 7+
- Fix test environment config (remove whiny_nils, show_exceptions)
- Upgrade mocha to ~> 2.0 with minitest integration
- Remove unused bson_ext dependency
- Fix integration tests to be self-contained across test runs
- Freeze time in TOTP tests to reduce flakiness at period boundaries

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Run tests on push and PR against Ruby 3.3 and 3.4.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The .to_i call on the token string strips leading zeros (e.g.
"012345" becomes 12345), which then fails to match the zero-padded
string from ROTP when compared via validate_token. Since
validate_token already calls .to_s internally, the token should
stay as a string throughout.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace the wall-clock-derived freeze with a fixed FROZEN_TIME
constant (5 seconds into a TOTP period). This eliminates test
ordering sensitivity where Timecop.travel in the remembertime test
left real time advancing, causing subsequent tests to land on
30-second TOTP boundaries. Also switches the remembertime and
ga_timeout tests to use Timecop.freeze with absolute times.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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