Skip to content

Commit

Permalink
Merge pull request #114 from jaydorsey/jaydorsey/association-style-ne…
Browse files Browse the repository at this point in the history
…sted-factory

FactoryBot/AssociationStyle nested factories
  • Loading branch information
ydah authored May 9, 2024
2 parents 86406bb + 0091c62 commit 0f0c954
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
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[
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

0 comments on commit 0f0c954

Please sign in to comment.