Commit b02076a
Support Rails 8.0 and 8.1 (#1686)
* Support Rails 8.0 and 8.1
The gemspec already allowed Rails 8.1 (`< 8.2`), but nothing in CI
exercised anything newer than Rails 7.0, so support past 7.0 was
asserted rather than verified. This adds real coverage.
- Add gemfiles/rails_8_0.gemfile and gemfiles/rails_8_1.gemfile, with
the Rails version pinned to the minor (`~> 8.0.0` / `~> 8.1.0`) so
each job tests the version it names.
- Add matching Appraisals entries.
- Add both gemfiles to the CI matrix, excluding Ruby < 3.2 since Rails 8
requires Ruby >= 3.2.
- Use `check_all_pending!` in the test helper when available;
`check_pending!` was deprecated in Rails 7.1 and removed in Rails 8.0.
- Widen the sqlite3 dev dependency, since Rails 8 needs sqlite3 2.x.
- Widen the mongoid dev dependency ceiling to `< 10`; mongoid 7.x caps
activemodel at `< 6.1`, which makes Rails 8 unresolvable.
- Bump the rails ceiling to `< 8.3` so 8.2 is allowed when it ships.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* Pin each gemfile to the Rails version it names
The gemfiles used `~> 7.0`-style constraints, which allow any 7.x. They
only resolved to the version in their filename because the `mongoid
'< 8'` dev dependency transitively capped activemodel and held Rails
down. Widening that ceiling for Rails 8 removed the cap, and
rails_7_0.gemfile silently began resolving to Rails 7.2 — which is what
made the omniauth tests fail.
Pin to the minor (`~> 7.0.0`) so each job tests the version it claims
and resolution cannot drift when an unrelated dependency changes.
* Revert "Pin each gemfile to the Rails version it names"
This reverts commit 6aba91b.
* Pin only the Rails 7.0 gemfiles
The blanket pin regressed rails_6_0.gemfile: it has been resolving to
Rails 6.1 all along, and the dummy app's legacy_connection_handling=
setting does not exist in real 6.0, so pinning it broke a previously
green row.
Pin only rails_7_0*, which needs it because widening the mongoid
ceiling removes the transitive cap that used to hold it at 7.0.
* Replace CGI.parse in the omniauth redirect for Ruby 3.5 / Rails 8.1
`CGI.parse` is no longer available in the cgi gem shipped with Ruby 3.5,
which Rails 8.1 pulls in. Every omniauth test errors with
`undefined method 'parse' for class CGI` at routes.rb:79.
Use `Rack::Utils.parse_query` instead. It returns a bare value for
single occurrences where `CGI.parse` returned a one-element array, so
normalize with `Array()` — downstream code does `qs['x'] = [resource]`
and `v.first` and depends on that shape.
Verified equivalent to `CGI.parse` for the inputs this route sees,
including repeated keys, bare keys, empty values, empty strings and
percent-encoded reserved characters. The only divergence is the legacy
`;` separator, which `Rack::Utils.parse_query` does not split on; that
form is long deprecated and does not occur in omniauth callbacks.
Rack is always loaded here since this file reopens
ActionDispatch::Routing::Mapper.
* Rewind the request body before re-reading it in the omniauth redirect
For POSTed omniauth requests the route falls back to `request.body.read`
when QUERY_STRING is empty. As of Rails 7.1 the body has typically
already been consumed by the time this redirect block runs, so `read`
returns "" and every param — auth_origin_url, omniauth_window_type,
resource_class — is silently dropped.
Rewind before reading. Guarded with respond_to? since not every rack
input is rewindable.
* Fix two test-side assumptions broken by newer Rails
Neither is a library bug; both are test expectations that no longer
match Rails behaviour.
1. Rails 7.2 changed `redirect_to` to set an empty response body
instead of the "You are being redirected" HTML snippet, so the
confirmations tests could no longer find the redirect URL in
`response.body`. Assert against `response.location`, which carries
the same URL on every supported version.
2. The dummy app's show_exceptions guard read
`MAJOR >= 7 && MINOR > 0`, which is false on Rails 8.0 (MINOR == 0),
so it set the pre-7.1 `false` value. Rails 7.1+ treats this setting
as an enum and an unrecognised value falls through to "render
exceptions", so the four `assert_raises` tests saw a rendered error
page instead of a raised exception. Compare with Rails.gem_version
instead. This is why those tests failed on 8.0 but not 8.1.
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent ec19d94 commit b02076a
11 files changed
Lines changed: 157 additions & 12 deletions
File tree
- .github/workflows
- gemfiles
- lib/devise_token_auth/rails
- test
- controllers/devise_token_auth
- dummy/config/environments
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
| |||
122 | 124 | | |
123 | 125 | | |
124 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
125 | 140 | | |
126 | 141 | | |
127 | 142 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
80 | 93 | | |
81 | 94 | | |
82 | 95 | | |
| |||
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
66 | | - | |
| 65 | + | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
90 | | - | |
| 89 | + | |
| 90 | + | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
36 | 39 | | |
37 | 40 | | |
38 | 41 | | |
| |||
0 commit comments