gitlab-org--gitlab-foss/spec/factories/uploads.rb

43 lines
1.0 KiB
Ruby
Raw Normal View History

FactoryBot.define do
factory :upload do
model { build(:project) }
size 100.kilobytes
uploader "AvatarUploader"
2017-12-06 11:36:11 +00:00
2018-01-29 17:57:34 +00:00
# we should build a mount agnostic upload by default
transient do
mounted_as :avatar
secret SecureRandom.hex
end
# this needs to comply with RecordsUpload::Concern#upload_path
path { File.join("uploads/-/system", model.class.to_s.underscore, mounted_as.to_s, 'avatar.jpg') }
trait :personal_snippet_upload do
2017-12-06 11:36:11 +00:00
model { build(:personal_snippet) }
2018-01-29 17:57:34 +00:00
path { File.join(secret, 'myfile.jpg') }
2017-12-06 11:36:11 +00:00
uploader "PersonalFileUploader"
end
trait :issuable_upload do
2018-01-29 17:57:34 +00:00
path { File.join(secret, 'myfile.jpg') }
2017-12-06 11:36:11 +00:00
uploader "FileUploader"
end
trait :namespace_upload do
model { build(:group) }
2018-01-29 17:57:34 +00:00
path { File.join(secret, 'myfile.jpg') }
2017-12-06 11:36:11 +00:00
uploader "NamespaceFileUploader"
end
2018-01-29 17:57:34 +00:00
trait :attachment_upload do
transient do
mounted_as :attachment
end
model { build(:note) }
uploader "AttachmentUploader"
end
end
end