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 takaokouji changed the base branch from setup-infrastructure to master November 10, 2025 03:18
@takaokouji takaokouji changed the base branch from master to setup-infrastructure November 10, 2025 03:18
takaokouji and others added 7 commits November 10, 2025 12:28
Enhance test coverage measurement capabilities:

Changes:
- Configure SimpleCov with detailed settings in test_helper.rb
  - Add filters to exclude test/, config/, vendor/ directories
  - Add coverage groups (Controllers, Resources, Serializers, etc.)
  - Enable branch coverage tracking (Ruby 2.5+)
  - Configure multi-format output (HTML + Console)
- Clean up .gitignore (remove duplicate coverage entry)
- Update .dockerignore to exclude coverage artifacts
- Add coverage instructions to CLAUDE.md (local & Docker)

Test results with Rails 6.1.7.10:
- Line Coverage: 92.04% (3491/3793 lines)
- Branch Coverage: 85.13% (853/1002 branches)
- All 674 tests passing

Usage:
  COVERAGE=true bundle exec rake test
  docker-compose run -e COVERAGE=true rails-6.1

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

Co-Authored-By: Claude <[email protected]>
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 <[email protected]>
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 <[email protected]>
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]>
Add full Rails 8.0 compatibility while maintaining backward compatibility
with Rails 6.1, 7.0, 7.1, and 7.2.

Key Changes:

1. SQLite3 Dependency Update:
   - Rails 8.0 requires sqlite3 >= 2.1 (was ~> 1.4)
   - Add conditional gem requirement in Gemfile:
     * Rails 8.x: sqlite3 >= 2.1
     * Rails 6-7: sqlite3 ~> 1.4
   - Use bundle lock --add-platform ruby for cross-platform support

2. Schema Format Configuration:
   - Rails 8.0 removed :none as valid schema_format option
   - Add version-conditional logic in test_helper.rb:
     * Rails 8.0+: Use :ruby format
     * Rails < 8.0: Use :none format (disables schema dumps)

Files Modified:
- Gemfile: Added Rails 8.x sqlite3 version condition
- test/test_helper.rb: Conditional schema_format based on Rails version

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

All backward compatibility maintained across Rails 6.1-8.0.

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

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