2017-12-14 00:13:44 +00:00
|
|
|
FactoryBot.define do
|
2017-06-08 03:32:38 +00:00
|
|
|
factory :upload do
|
2017-08-02 19:55:11 +00:00
|
|
|
model { build(:project) }
|
2017-06-08 03:32:38 +00:00
|
|
|
size 100.kilobytes
|
|
|
|
uploader "AvatarUploader"
|
2018-01-29 21:06:17 +00:00
|
|
|
mount_point :avatar
|
|
|
|
secret nil
|
2018-02-21 16:43:21 +00:00
|
|
|
store ObjectStorage::Store::LOCAL
|
2017-12-06 11:36:11 +00:00
|
|
|
|
2018-02-02 13:59:43 +00:00
|
|
|
# we should build a mount agnostic upload by default
|
|
|
|
transient do
|
2018-01-29 21:06:17 +00:00
|
|
|
filename 'myfile.jpg'
|
2018-02-02 13:59:43 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# this needs to comply with RecordsUpload::Concern#upload_path
|
2018-01-29 21:06:17 +00:00
|
|
|
path { File.join("uploads/-/system", model.class.to_s.underscore, mount_point.to_s, 'avatar.jpg') }
|
2018-02-02 13:59:43 +00:00
|
|
|
|
|
|
|
trait :personal_snippet_upload do
|
2017-12-06 11:36:11 +00:00
|
|
|
uploader "PersonalFileUploader"
|
2018-01-29 21:06:17 +00:00
|
|
|
path { File.join(secret, filename) }
|
|
|
|
model { build(:personal_snippet) }
|
|
|
|
secret SecureRandom.hex
|
2017-12-06 11:36:11 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
trait :issuable_upload do
|
|
|
|
uploader "FileUploader"
|
2018-01-29 21:06:17 +00:00
|
|
|
path { File.join(secret, filename) }
|
|
|
|
secret SecureRandom.hex
|
2017-12-06 11:36:11 +00:00
|
|
|
end
|
|
|
|
|
2018-02-21 16:43:21 +00:00
|
|
|
trait :object_storage do
|
|
|
|
store ObjectStorage::Store::REMOTE
|
|
|
|
end
|
|
|
|
|
2017-12-06 11:36:11 +00:00
|
|
|
trait :namespace_upload do
|
|
|
|
model { build(:group) }
|
2018-01-29 21:06:17 +00:00
|
|
|
path { File.join(secret, filename) }
|
2017-12-06 11:36:11 +00:00
|
|
|
uploader "NamespaceFileUploader"
|
2018-01-29 21:06:17 +00:00
|
|
|
secret SecureRandom.hex
|
2017-12-06 11:36:11 +00:00
|
|
|
end
|
2018-02-02 13:59:43 +00:00
|
|
|
|
|
|
|
trait :attachment_upload do
|
|
|
|
transient do
|
2018-01-29 21:06:17 +00:00
|
|
|
mount_point :attachment
|
2018-02-02 13:59:43 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
model { build(:note) }
|
|
|
|
uploader "AttachmentUploader"
|
|
|
|
end
|
2017-06-08 03:32:38 +00:00
|
|
|
end
|
|
|
|
end
|