Skip to content

Upgrade to Rails 8.1 and Devise 5 - #395

Merged
motizuki merged 15 commits into
mainfrom
gm/rails-8-1
Nov 26, 2026
Merged

motizuki merged 15 commits into
mainfrom
gm/rails-8-1

Conversation

@motizuki

@motizuki motizuki commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Why

Rails 7.2 is out of security support. This moves the engine to Rails 8.1 (target 8.1.4.1) and devise 5.

This branch also contains the unique-index fix (ee2450c) and the .ruby-version bump to 3.4.13. It supersedes the separate v4.3.2 release plan and ships as v5.0.0 (breaking: requires Rails 8.1).

What changed

  • Gemspec pins moved to Rails ~> 8.1.4.
  • active_model_serializers floor raised to 0.10.16 (0.10.14 raises FrozenError on Rails 8.1 because the JSON encoder options are frozen).
  • Audit-driven bumps: rack 2.2.25, dalli 3.2.17, mongo 2.26.2, mongoid 9.1.2, addressable 2.9.2, crass 1.0.8. Rails-forced: rails-html-sanitizer 1.7.2, loofah 2.25.3, nokogiri 1.19.7.
  • devise 4.9.4 -> 5.0.4. devise-token_authenticatable is removed (it caps devise < 5 and is unmaintained). The token generator now lives in SupplejackApi::User#ensure_authentication_token, unchanged, so existing API keys keep working and stored tokens are never rewritten.
  • Status controller uses a monotonic clock.
  • Golden output spec (JSON/XML, status, media types) plus a test config that raises on engine-originated Rails deprecations. The golden fixtures are unchanged by the upgrade.

Breaking changes for engine consumers

  • Requires Rails 8.1.
  • devise-token_authenticatable is removed. These are gone:
    • reset_authentication_token and reset_authentication_token!
    • ensure_authentication_token!
    • find_for_token_authentication
    • the Warden token authentication strategy
    • Devise.token_authentication_key. A host app that still has an uncommented config.token_authentication_key in its devise initializer will fail at boot.
  • ensure_authentication_token is kept, with identical behaviour.

Version

v5.0.0 (constant bumped; tag after merge).

Kept as is

  • rack ~> 2.2.4
  • sunspot 2.4.0 (no patch needed)
  • connection_pool ~> 2.5 (sidekiq 7.3 calls pop with a positional timeout)
  • config.load_defaults untouched

Remaining deprecations

Gem-originated: activeresource 6.0.0 (ActiveJobSerializer#klass should be public, becomes an error on Rails 8.2).

Verification

Full suite: 1001 examples, 0 failures, 4 pending. rubocop, bundle-audit (no ignore list) and brakeman clean. reek total is back to 630.

Host apps

The api and pvm-api MRs will follow, pointing at this branch.

mrGrazy and others added 10 commits November 20, 2026 10:17
- ubuntu-latest (26.04) runners no longer provide 3.4.4, so setup-ruby fails every job
- add golden request spec for record, search and forbidden JSON/XML output
- raise on deprecations from engine code, warn on stderr for gem-originated ones
- match exact Rails gem names so active_model_serializers frames count as gems
- treat any frame outside the engine root or under bundler paths as gem-originated
- add classification spec and assert Content-Type on golden responses
- take a splat after callstack so ActiveSupport::Deprecation can call the behavior with horizon and gem name
- add a spec that wires the behavior into a real deprecator and expects an engine-originated warning to raise
- replace Benchmark.ms, which Rails 8.1 no longer provides, with Process.clock_gettime in milliseconds
- rails, activerecord, activesupport: ~> 7.2.3.2 -> ~> 8.1.4 (resolved 8.1.4.1)
- active_model_serializers: require >= 0.10.16 (0.10.14 -> 0.10.16); 0.10.14 mutates the options hash Rails 8.1 freezes during JSON encoding and loads the deprecated ActiveSupport::Configurable
- audit-driven bumps: rack 2.2.23 -> 2.2.25, dalli 3.2.8 -> 3.2.17, mongo 2.25.0 -> 2.26.2, mongoid 9.1.0 -> 9.1.2, addressable 2.9.0 -> 2.9.2, crass 1.0.7 -> 1.0.8
- drop the brakeman ignore entry for the end-of-life rails 7.2 warning
- assert an over-limit anonymous key gets 403, application/xml and the anonymous limit message
- rails 8.1 passes keyword arguments to ConnectionPool.new, so the remaining blocker is sidekiq 7.3.0 calling TimedStack#pop with a positional timeout
…enticatable

- move the token generator into SupplejackApi::User unchanged, so existing keys keep working
- pin devise to ~> 5.0 and remove the unmaintained devise-token_authenticatable
- add model specs for token generation and a request spec for header and param api keys
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Code quality score

Lovely, the code quality is unchanged for this PR 😊

Ruby file count Similarity score (flay) ABC complexity (flog) Code smells (reek) TOTALS
base 146 3.34 7.92 21.6 32.86
this branch 146 3.34 7.92 21.6 32.86
difference 0 0.0 0.0 0.0 0.0

- move the unique-token loop out of ensure_authentication_token into generate_authentication_token to clear the reek TooManyStatements smell
- annotate StatusController#handle_timeout for reek DuplicateMethodCall, since the clock is read before and after the block on purpose
- assert legacy-token requests are counted against the token's user via daily_requests
- add the "wired into the Rails application deprecators" example the apps already have
- update the activesupport and active_model_serializers frame strings to 8.1.4.1 and 0.10.16
@motizuki
motizuki marked this pull request as ready for review November 20, 2026 00:29
@motizuki motizuki changed the title build(deps): upgrade to rails 8.1 and devise 5 Upgrade to Rails 8.1 and Devise 5 Nov 20, 2026

@paul-mesnilgrente paul-mesnilgrente left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've got 2 important comments, let's check this out next week

Comment thread supplejack_api.gemspec Resolved
Comment thread app/models/supplejack_api/user.rb Resolved
@motizuki
motizuki merged commit 38ecd53 into main Nov 26, 2026
5 checks passed
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.

5 participants