Skip to content

Conversation

@takaokouji
Copy link
Collaborator

Add full Rails 7.2 compatibility while maintaining backward compatibility with Rails 6.1, 7.0, and 7.1.

Key Changes:

  1. Deprecation API Updates (Rails 7.2 made methods private):

    • Add JSONAPI.warn_deprecated() helper method
    • Replace all ActiveSupport::Deprecation.warn calls
    • Handle ActiveSupport::Deprecation.silenced= conditionally in tests
    • Falls back to Kernel#warn with [DEPRECATION] prefix for Rails 7.2+
  2. Configuration Initialization Fix:

    • Change from attr_accessor to custom getter method
    • Ensures @configuration ||= Configuration.new works reliably
    • Fixed "undefined method for nil" errors in 304 tests
  3. Test Fixture Path Changes:

    • Rails 7.2 changed fixture_path= to fixture_paths= (array)
    • Add conditional handling in three test classes:
      • Minitest::Test
      • ActiveSupport::TestCase * ActionDispatch::IntegrationTest
  4. Test Helper Deprecation Silencing:

    • Update test_helper.rb to handle Rails 7.2 deprecators API
    • Conditional logic for silencing deprecation warnings

Files Modified:

  • lib/jsonapi/configuration.rb: Added warn_deprecated helper + fixed getter
  • lib/jsonapi/basic_resource.rb: Use JSONAPI.warn_deprecated
  • lib/jsonapi/acts_as_resource_controller.rb: Use JSONAPI.warn_deprecated
  • lib/jsonapi/relationship.rb: Use JSONAPI.warn_deprecated
  • test/test_helper.rb: Fixture paths + deprecation silencing
  • test/unit/resource/resource_test.rb: Conditional silenced= handling
  • test/integration/requests/request_test.rb: Conditional silenced= handling

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

🤖 Generated with Claude Code

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

Add full Rails 7.2 compatibility while maintaining backward compatibility
with Rails 6.1, 7.0, and 7.1.

Key Changes:

1. Deprecation API Updates (Rails 7.2 made methods private):
   - Add JSONAPI.warn_deprecated() helper method
   - Replace all ActiveSupport::Deprecation.warn calls
   - Handle ActiveSupport::Deprecation.silenced= conditionally in tests
   - Falls back to Kernel#warn with [DEPRECATION] prefix for Rails 7.2+

2. Configuration Initialization Fix:
   - Change from attr_accessor to custom getter method
   - Ensures @configuration ||= Configuration.new works reliably
   - Fixed "undefined method for nil" errors in 304 tests

3. Test Fixture Path Changes:
   - Rails 7.2 changed fixture_path= to fixture_paths= (array)
   - Add conditional handling in three test classes:
     * Minitest::Test
     * ActiveSupport::TestCase
     * ActionDispatch::IntegrationTest

4. Test Helper Deprecation Silencing:
   - Update test_helper.rb to handle Rails 7.2 deprecators API
   - Conditional logic for silencing deprecation warnings

Files Modified:
- lib/jsonapi/configuration.rb: Added warn_deprecated helper + fixed getter
- lib/jsonapi/basic_resource.rb: Use JSONAPI.warn_deprecated
- lib/jsonapi/acts_as_resource_controller.rb: Use JSONAPI.warn_deprecated
- lib/jsonapi/relationship.rb: Use JSONAPI.warn_deprecated
- test/test_helper.rb: Fixture paths + deprecation silencing
- test/unit/resource/resource_test.rb: Conditional silenced= handling
- test/integration/requests/request_test.rb: Conditional silenced= handling

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

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

Co-Authored-By: Claude <[email protected]>
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