Add ActiveModel::Attributes model-reader tests + CHANGELOG for Type#cast - #3
Merged
HoneyryderChuck merged 1 commit intoJul 16, 2026
Conversation
The existing Type#cast specs assert the type in isolation. Add model-level regression coverage using a model whose enumerize attributes are declared without a preceding plain `attribute`, so on Rails 8.1 the generated reader outranks enumerize's module and reads resolve through #cast. Without the #cast override these fail with a raw String/Symbol; value predicates then raise NoMethodError. Also add a CHANGELOG entry for the #cast fix. Verified on Rails 8.1.3, 8.0.5 and 7.2.3.1 (Ruby 3.3.6). Refs brainspec#482 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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
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.
Stacked on top of brainspec#476. Test and CHANGELOG coverage only — no change to the
#castimplementation from that PR.What's here
#castfix.CastActiveModelUserfixture, covering: predicate after assignment, wrapping an after-init assignment, the wrapped default,nilhandling, invalid-value validation, andmultiple: truestaying anEnumerize::Set.Why these tests
The existing
Type#castspecs assert the type in isolation (type.cast(...)), which passes regardless of the ancestor-chain ordering that actually regressed on Rails 8.1. The new fixture reproduces the exposed path — the code comments onCastActiveModelUserand thedescribe 'Type#cast (model reader)'block explain the ordering mechanism and exactly which examples fail without the#castoverride.Validation
Green on Rails 8.1.3, 8.0.5, and 7.2.3.1 (Ruby 3.3.6):
33 runs, 60 assertions, 0 failures.Root-cause write-up: brainspec#482. Related Rails-side report: rails/rails#53985.