-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
BugFix: '<attribute>' and '<attribute>_id' conflict. #1709
base: main
Are you sure you want to change the base?
BugFix: '<attribute>' and '<attribute>_id' conflict. #1709
Conversation
I had expected this problem to be much more difficult to resolve, but can't find anything wrong with your code, good job 🙌 When trying to understand the conflict ignored attributes - that as far as I've seen only applies to transient ones - makes the processing hard to understand. I think you managed well to make this easier to grasp. |
def attribute_names | ||
@attribute_list.names | ||
end | ||
|
||
def hash_instance_methods_to_respond_to | ||
@attribute_list.names + override_names + @build_class.instance_methods |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use attribute_names
? side note: just lost a number of hours on the bug this PR will solve 😢 , thank you for working to fix it! 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- AttributeAssigner refactored to ignore a matching attribute alias, if it also matches the name of another attribute. - Tests added for attribute assignment.
- Gemfile update from rebasing on main.
832cfe7
to
3dde8e6
Compare
Fixes: #1680
Fixes: #1142
Addresses: #1708
When a factory has both <attribute> and <attribute>_id, each one is considered an alias for the other
and are not assigned correctly.
This request eliminates this issue by checking if the override is an existing attribute name, before matching against an alias.
It works for any recorded aliases, not just '_id'.