Commit 8b043949 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'al-rubocop-inline-association' into 'master'

Fix cop FactoryBot/InlineAssociation for wiki pages/uploads

See merge request gitlab-org/gitlab!46393
parents 50ceac09 975b36c6
......@@ -1275,5 +1275,3 @@ FactoryBot/InlineAssociation:
- 'spec/factories/packages.rb'
- 'spec/factories/packages/package_file.rb'
- 'spec/factories/sent_notifications.rb'
- 'spec/factories/uploads.rb'
- 'spec/factories/wiki_pages.rb'
......@@ -2,7 +2,7 @@
FactoryBot.define do
factory :upload do
model { create(:project) }
model { association(:project) }
size { 100.kilobytes }
uploader { "AvatarUploader" }
mount_point { :avatar }
......@@ -20,7 +20,7 @@ FactoryBot.define do
end
trait :personal_snippet_upload do
model { create(:personal_snippet) }
model { association(:personal_snippet) }
path { File.join(secret, filename) }
uploader { "PersonalFileUploader" }
secret { SecureRandom.hex }
......@@ -46,7 +46,7 @@ FactoryBot.define do
end
trait :namespace_upload do
model { create(:group) }
model { association(:group) }
path { File.join(secret, filename) }
uploader { "NamespaceFileUploader" }
secret { SecureRandom.hex }
......@@ -54,7 +54,7 @@ FactoryBot.define do
end
trait :favicon_upload do
model { create(:appearance) }
model { association(:appearance) }
uploader { "FaviconUploader" }
secret { SecureRandom.hex }
mount_point { :favicon }
......@@ -62,13 +62,13 @@ FactoryBot.define do
trait :attachment_upload do
mount_point { :attachment }
model { create(:note) }
model { association(:note) }
uploader { "AttachmentUploader" }
end
trait :design_action_image_v432x230_upload do
mount_point { :image_v432x230 }
model { create(:design_action) }
model { association(:design_action) }
uploader { ::DesignManagement::DesignV432x230Uploader.name }
end
end
......
......@@ -39,14 +39,14 @@ FactoryBot.define do
factory :wiki_page_meta, class: 'WikiPage::Meta' do
title { generate(:wiki_page_title) }
project { create(:project) }
project { association(:project) }
trait :for_wiki_page do
transient do
wiki_page { create(:wiki_page, container: project) }
wiki_page { association(:wiki_page, container: project) }
end
project { @overrides[:wiki_page]&.container || create(:project) }
project { @overrides[:wiki_page]&.container || association(:project) }
title { wiki_page.title }
initialize_with do
......@@ -58,7 +58,7 @@ FactoryBot.define do
end
factory :wiki_page_slug, class: 'WikiPage::Slug' do
wiki_page_meta { create(:wiki_page_meta) }
wiki_page_meta { association(:wiki_page_meta) }
slug { generate(:sluggified_title) }
canonical { false }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment