diff options
Diffstat (limited to 'spec/factories/uploads.rb')
-rw-r--r-- | spec/factories/uploads.rb | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/spec/factories/uploads.rb b/spec/factories/uploads.rb index c39500faea1..ff3a2a76acc 100644 --- a/spec/factories/uploads.rb +++ b/spec/factories/uploads.rb @@ -1,24 +1,46 @@ FactoryBot.define do factory :upload do model { build(:project) } - path { "uploads/-/system/project/avatar/avatar.jpg" } size 100.kilobytes uploader "AvatarUploader" + mount_point :avatar + secret nil - trait :personal_snippet do - model { build(:personal_snippet) } + # we should build a mount agnostic upload by default + transient do + filename 'myfile.jpg' + end + + # this needs to comply with RecordsUpload::Concern#upload_path + path { File.join("uploads/-/system", model.class.to_s.underscore, mount_point.to_s, 'avatar.jpg') } + + trait :personal_snippet_upload do uploader "PersonalFileUploader" + path { File.join(secret, filename) } + model { build(:personal_snippet) } + secret SecureRandom.hex end trait :issuable_upload do - path { "#{SecureRandom.hex}/myfile.jpg" } uploader "FileUploader" + path { File.join(secret, filename) } + secret SecureRandom.hex end trait :namespace_upload do - path { "#{SecureRandom.hex}/myfile.jpg" } model { build(:group) } + path { File.join(secret, filename) } uploader "NamespaceFileUploader" + secret SecureRandom.hex + end + + trait :attachment_upload do + transient do + mount_point :attachment + end + + model { build(:note) } + uploader "AttachmentUploader" end end end |