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
Allow #traits_for_enum
to be used in a FactoryBot
factory without a block
#944
Allow #traits_for_enum
to be used in a FactoryBot
factory without a block
#944
Conversation
ATTRIBUTE_DEFINING_METHODS = %i[factory trait transient ignore].freeze | ||
ATTRIBUTE_DEFINING_METHODS = %i[ | ||
factory | ||
ignore | ||
trait | ||
traits_for_enum | ||
transient | ||
].freeze |
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.
Adding :traits_for_enum
caused a Layout/LineLength
offense, so I turned the horizontal list into a vertical list. I also alphabetized the list to align with what was done with the other constants below.
One of the non-required builds failed, |
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.
Thanks a lot!
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.
You need to add s Changelog entry though
@Darhazer I added a Also, regarding the checklist item "squashed related commits together", I'm not sure if it means to squash all commits in the branch into one, or if it is good enough to make sure the PR is merged into |
241f3b5
to
e2a8382
Compare
I didn't realize at first what was required to fill out a |
This PR fixes a bug that arose in relation to FactoryBot's recent
6.0.0
version release. This release introduced a new method,#traits_for_enum
, which can be used to dynamically define factory traits for an enumerated attribute.The behaviour expected is that usage of this method (which does not take a block argument) does not produce a
FactoryBot/AttributeDefinedStatically
offense.The actual behaviour is that it does produce this offense because it is assumed to be an attribute, which should be defined with a block. The fix is simply to add it to the list of pre-qualified methods.
The documentation surrounding this cop does not make any mention around what methods are allowed to be used without a block, so I didn't feel it was necessary to update the documentation.
I believe this constitutes a "user-observable" change, but am not sure. If you feel it does, I will add a commit to add an entry to the
CHANGELOG.md
.This fixes #943.
Before submitting the PR make sure the following are checked:
master
(if not - rebase it).CHANGELOG.md
if the new code introduces user-observable changes.bundle exec rake
) passes (be sure to run this locally, since it may produce updated documentation that you will need to commit).