Skip to content
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

FactoryBot/AssociationStyle nested factories #114

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Master (Unreleased)

- Fix a false positive for `FactoryBot/AssociationStyle` when using nested factories with traits. ([@jaydorsey])

## 2.25.1 (2024-01-08)

- Fix a false positive for `FactoryBot/CreateList` when create call does have method calls and repeat multiple times with other argument. ([@ydah])
Expand Down Expand Up @@ -88,6 +90,7 @@
[@ddieulivol]: https://github.com/ddieulivol
[@dmitrytsepelev]: https://github.com/dmitrytsepelev
[@harrylewis]: https://github.com/harrylewis
[@jaydorsey]: https://github.com/jaydorsey
[@jfragoulis]: https://github.com/jfragoulis
[@jonatas]: https://github.com/jonatas
[@leoarnold]: https://github.com/leoarnold
Expand Down
1 change: 1 addition & 0 deletions lib/rubocop/cop/factory_bot/association_style.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class AssociationStyle < ::RuboCop::Cop::Base # rubocop:disable Metrics/ClassLen

DEFAULT_NON_IMPLICIT_ASSOCIATION_METHOD_NAMES = %w[
pirj marked this conversation as resolved.
Show resolved Hide resolved
association
factory
sequence
skip_create
traits_for_enum
Expand Down
14 changes: 14 additions & 0 deletions spec/rubocop/cop/factory_bot/association_style_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -405,5 +405,19 @@ def inspected_source_filename
RUBY
end
end

context 'when factory inside a factory with inline traits' do
it 'does not register an offense' do
expect_no_offenses(<<~RUBY)
factory :order do
traits :completed do
completed_at { 3.days.ago }
end
factory :order_completed, traits: [:completed]
end
RUBY
end
end
end
end