diff --git a/.rubocop_manual_todo.yml b/.rubocop_manual_todo.yml index 9b20af55520e31a9bcc5d8be04ba10fd0a2d2107..97217081e29d560d112d549aafbaac01bec9f39c 100644 --- a/.rubocop_manual_todo.yml +++ b/.rubocop_manual_todo.yml @@ -41,16 +41,6 @@ Graphql/Descriptions: - 'ee/app/graphql/types/vulnerability_severity_enum.rb' - 'ee/app/graphql/types/vulnerability_state_enum.rb' -# WIP See https://gitlab.com/gitlab-org/gitlab/-/issues/267606 -FactoryBot/InlineAssociation: - Exclude: - - 'spec/factories/atlassian_identities.rb' - - 'spec/factories/events.rb' - - 'spec/factories/git_wiki_commit_details.rb' - - 'spec/factories/gitaly/commit.rb' - - 'spec/factories/group_group_links.rb' - - 'spec/factories/import_export_uploads.rb' - # WIP: See https://gitlab.com/gitlab-org/gitlab/-/issues/220040 Rails/SaveBang: Exclude: diff --git a/spec/factories/atlassian_identities.rb b/spec/factories/atlassian_identities.rb index 698cf4ae7ad2157509776861ec63fd638ac5c173..80420e335a9618b10780bc9d786640d6bded2c67 100644 --- a/spec/factories/atlassian_identities.rb +++ b/spec/factories/atlassian_identities.rb @@ -3,7 +3,7 @@ FactoryBot.define do factory :atlassian_identity, class: 'Atlassian::Identity' do extern_uid { generate(:username) } - user { create(:user) } + user { association(:user) } expires_at { 2.weeks.from_now } token { SecureRandom.alphanumeric(1254) } refresh_token { SecureRandom.alphanumeric(45) } diff --git a/spec/factories/events.rb b/spec/factories/events.rb index 6c9f1ba01371a58b1b25a04f46f39fdeac34dbb9..c9e4ada3ffa3972baec9536dd4dc9bf53e436025 100644 --- a/spec/factories/events.rb +++ b/spec/factories/events.rb @@ -27,17 +27,20 @@ factory :wiki_page_event do action { :created } + # rubocop: disable FactoryBot/InlineAssociation + # A persistent project is needed to have a wiki page being created properly. project { @overrides[:wiki_page]&.container || create(:project, :wiki_repo) } - target { create(:wiki_page_meta, :for_wiki_page, wiki_page: wiki_page) } + # rubocop: enable FactoryBot/InlineAssociation + target { association(:wiki_page_meta, :for_wiki_page, wiki_page: wiki_page) } transient do - wiki_page { create(:wiki_page, container: project) } + wiki_page { association(:wiki_page, container: project) } end end trait :has_design do transient do - design { create(:design, issue: create(:issue, project: project)) } + design { association(:design, issue: association(:issue, project: project)) } end end @@ -45,7 +48,7 @@ has_design transient do - note { create(:note, author: author, project: project, noteable: design) } + note { association(:note, author: author, project: project, noteable: design) } end action { :commented } diff --git a/spec/factories/git_wiki_commit_details.rb b/spec/factories/git_wiki_commit_details.rb index b35f102fd4dba1e51e184be5e15b757eaa53bd81..fb3f2954b12934e7ef10b6fd01f7d84081f05334 100644 --- a/spec/factories/git_wiki_commit_details.rb +++ b/spec/factories/git_wiki_commit_details.rb @@ -5,7 +5,7 @@ skip_create transient do - author { create(:user) } + author { association(:user) } end sequence(:message) { |n| "Commit message #{n}" } diff --git a/spec/factories/gitaly/commit.rb b/spec/factories/gitaly/commit.rb index 2ed201e9aacf952cc2bfed898688de05d0f7f11a..4e8220e449a58df604cca5524a6d65e6cc6c5148 100644 --- a/spec/factories/gitaly/commit.rb +++ b/spec/factories/gitaly/commit.rb @@ -14,7 +14,7 @@ subject { "My commit" } body { subject + "\nMy body" } - author { build(:gitaly_commit_author) } - committer { build(:gitaly_commit_author) } + author { association(:gitaly_commit_author) } + committer { association(:gitaly_commit_author) } end end diff --git a/spec/factories/group_group_links.rb b/spec/factories/group_group_links.rb index 6f98886faffb3dde00962f59f96eb4b6a98a7ffa..2a582d8525b0d5e1a566943aa40fbe3be88b142e 100644 --- a/spec/factories/group_group_links.rb +++ b/spec/factories/group_group_links.rb @@ -2,8 +2,8 @@ FactoryBot.define do factory :group_group_link do - shared_group { create(:group) } - shared_with_group { create(:group) } + shared_group { association(:group) } + shared_with_group { association(:group) } group_access { Gitlab::Access::DEVELOPER } trait(:guest) { group_access { Gitlab::Access::GUEST } } diff --git a/spec/factories/import_export_uploads.rb b/spec/factories/import_export_uploads.rb index 8521411e0e81463559c74e461787114901afc3a7..e1dd0c10ff266d8d98fb2031c50f3b2265e5921e 100644 --- a/spec/factories/import_export_uploads.rb +++ b/spec/factories/import_export_uploads.rb @@ -2,6 +2,6 @@ FactoryBot.define do factory :import_export_upload do - project { create(:project) } + project { association(:project) } end end