forked from cerebris/jsonapi-resources
-
Notifications
You must be signed in to change notification settings - Fork 1
Rails 7.0-8.1 support (full version up) #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
takaokouji
wants to merge
7
commits into
setup-infrastructure
Choose a base branch
from
rails-8.1-support
base: setup-infrastructure
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]>
f6306d4 to
910fed4
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
All Submissions:
New Feature Submissions:
Bug fixes and Changes to Core Features:
Test Plan:
Reviewer Checklist: