Skip to content

Conversation

@takaokouji
Copy link
Collaborator

All Submissions:

  • I've checked to ensure there aren't other open Pull Requests for the same update/change.
  • I've submitted a ticket for my issue if one did not already exist.
  • My submission passes all tests. (Please run the full test suite locally to cut down on noise from travis failures.)
  • I've used Github auto-closing keywords in the commit message or the description.
  • I've added/updated tests for this change.

New Feature Submissions:

  • I've submitted an issue that describes this feature, and received the go ahead from the maintainers.
  • My submission includes new tests.
  • My submission maintains compliance with JSON:API.

Bug fixes and Changes to Core Features:

  • I've included an explanation of what the changes do and why I'd like you to include them.
  • I've provided test(s) that fails without the change.

Test Plan:

Reviewer Checklist:

  • Maintains compliance with JSON:API
  • Adequate test coverage exists to prevent regressions

takaokouji and others added 2 commits November 10, 2025 12:30
Implement Rails 7.1 compatibility fixes while maintaining backward
compatibility with Rails 6.1 and 7.0:

Changes:
- Fix version-conditional app initialization in test_helper.rb
  - Rails 7.1+ requires TestApp.initialize! before rails/test_help
  - Rails 6.1/7.0 require opposite order
- Fix schema compatibility in active_record.rb
  - Change t.string :length option to :limit (Rails 7.1 deprecation)
  - Change t.references :references option to foreign_key: false
- Disable SQLite foreign key constraints in test environment
  - Rails 7.1 enables strict FK constraints by default
  - Added PRAGMA foreign_keys = OFF for test compatibility

Backward compatibility verified:
- Rails 6.1.7.10: ✅ 674/674 tests passing
- Rails 7.0.10: ✅ 674/674 tests passing

Rails 7.1.6 status:
- 664/674 tests passing (98.5%)
- 1 failure: RequestTest expecting 422, got 0
- 9 errors: "Invalid response code: 0" in controller tests

Remaining work:
- Investigate and fix response code 0 errors
- Get all 674 tests passing in Rails 7.1.6

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
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>
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