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