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:33
Fix Rails 8.1 routing API breaking changes for Resource and
SingletonResource initialization.

Key Changes:

1. Routing API Update (Rails 8.1):
   - Rails 8.1 changed Resource.new and SingletonResource.new signatures
   - Removed 4th parameter (options) from both constructors
   - Updated signatures:
     * Before: Resource.new(type, api_only, shallow, options)
     * After:  Resource.new(type, api_only, shallow)
   - Add version-conditional logic in routing_ext.rb:
     * Rails 8.1+: Use 3-argument constructor
     * Rails < 8.1: Use 4-argument constructor

Files Modified:
- lib/jsonapi/routing_ext.rb:
  * Fixed Resource.new call (line ~138)
  * Fixed SingletonResource.new call (line ~64)

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
- Rails 7.2.3: ✅ 674/674 tests passing
- Rails 8.0.4: ✅ 674/674 tests passing
- Rails 8.1.1: ⚠️ 664/674 tests passing (10 failures)

Rails 8.1 Remaining Issues (10 test failures):
1. JoinTreeTest: SQL generation issue (1 failure)
2. RequestTest: Relationship route 404 errors (5 failures)
3. RequestTest: JSON parse error message format change (4 failures)

All backward compatibility maintained for Rails 6.1-8.0.
Rails 8.1 is partially supported pending investigation of remaining failures.

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

Co-Authored-By: Claude <noreply@anthropic.com>
Rails 8.1 introduced several breaking changes that required updates
across routing, testing, and SQL generation:

Routing changes (lib/jsonapi/routing_ext.rb):
- Rails 8.1 changed Scope to not support []= operator
- Resource.new signature changed (removed options parameter)
- Solution: Use @jsonapi_resource_type instance variable to track
  resource type instead of @scope[:jsonapi_resource]
- Updated resource_type_with_module_prefix to check instance variable
- Maintains backward compatibility with Rails 4-8.0

Test compatibility (test/integration/requests/request_test.rb):
- Rails 8.1 has more detailed JSON parse error messages
- Updated test_put_invalid_json to accept multiple error formats
- Now matches: "unexpected token at" OR "expected ... got:" OR "parse error"

SQLite boolean representation (test/unit/active_relation_resource_finder/join_manager_test.rb):
- Rails 8.1+ SQLite now uses TRUE instead of 1 for boolean values
- Updated db_true helper with version check for Rails 8.1+
- Maintains support for older Rails versions (5.x-8.0)

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 ✓
- Rails 7.2.3: 674/674 tests passing ✓
- Rails 8.0.4: 674/674 tests passing ✓
- Rails 8.1.1: 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