Commit 5e53504
Complete Rails 7.1.6 support with Rack 3.0 compatibility
Fix status code handling for Rack 3.0+ compatibility:
Root cause:
- Rack 3.0+ deprecated :unprocessable_entity symbol in favor of :unprocessable_content
- When JSONAPI::Error looked up :unprocessable_entity in Rack::Utils::SYMBOL_TO_STATUS_CODE,
it returned nil, causing response status to be 0 instead of 422
- This broke 10 tests that expected proper error status codes
Solution:
- Add DEPRECATED_STATUS_SYMBOLS mapping in JSONAPI::Error
- Implement status_code_for() helper method that:
1. Tries the symbol directly first (works for all non-deprecated symbols)
2. Falls back to new symbol if deprecated symbol not found
3. Returns nil-safe string result
- Apply helper to both initialize() and update_with_overrides() methods
This maintains full backward compatibility:
- Rails 6.1 with Rack 2.x: :unprocessable_entity works directly
- Rails 7.0 with Rack 2.x: :unprocessable_entity works directly
- Rails 7.1+ with Rack 3.x: :unprocessable_entity maps to :unprocessable_content
Test results:
- Rails 6.1.7.10: ✅ 674/674 tests passing
- Rails 7.0.10: ✅ 674/674 tests passing
- Rails 7.1.6: ✅ 674/674 tests passing
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 1f84070 commit 5e53504
3 files changed
+22
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
7 | 27 | | |
8 | 28 | | |
9 | 29 | | |
| |||
17 | 37 | | |
18 | 38 | | |
19 | 39 | | |
20 | | - | |
| 40 | + | |
21 | 41 | | |
22 | 42 | | |
23 | 43 | | |
| |||
48 | 68 | | |
49 | 69 | | |
50 | 70 | | |
51 | | - | |
| 71 | + | |
52 | 72 | | |
53 | 73 | | |
54 | 74 | | |
| |||
Binary file not shown.
Binary file not shown.
0 commit comments