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) }
|
2018-09-20 13:02:36 -04:00
|
|
|
size { 100.kilobytes }
|
2017-06-07 23:32:38 -04:00
|
|
|
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
|
2019-05-11 08:06:44 -04:00
|
|
|
path { File.join("uploads/-/system", model.class.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) }
|
2018-09-20 13:02:36 -04:00
|
|
|
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) }
|
2018-09-20 13:02:36 -04:00
|
|
|
secret { SecureRandom.hex }
|
2017-12-06 06:36:11 -05:00
|
|
|
end
|
|
|
|
|
2018-07-10 10:33:40 -04:00
|
|
|
trait :with_file do
|
|
|
|
after(:create) do |upload|
|
|
|
|
FileUtils.mkdir_p(File.dirname(upload.absolute_path))
|
|
|
|
FileUtils.touch(upload.absolute_path)
|
|
|
|
end
|
|
|
|
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-09-20 13:02:36 -04:00
|
|
|
secret { SecureRandom.hex }
|
2017-12-06 06:36:11 -05:00
|
|
|
end
|
2018-02-02 08:59:43 -05:00
|
|
|
|
2018-08-14 12:21:48 -04:00
|
|
|
trait :favicon_upload do
|
|
|
|
model { build(:appearance) }
|
|
|
|
path { File.join(secret, filename) }
|
|
|
|
uploader "FaviconUploader"
|
2018-09-20 13:02:36 -04:00
|
|
|
secret { SecureRandom.hex }
|
2018-08-14 12:21:48 -04:00
|
|
|
end
|
|
|
|
|
2018-02-02 08:59:43 -05:00
|
|
|
trait :attachment_upload do
|
2019-06-09 08:56:11 -04:00
|
|
|
transient do
|
|
|
|
mount_point :attachment
|
|
|
|
end
|
|
|
|
|
2018-02-02 08:59:43 -05:00
|
|
|
model { build(:note) }
|
|
|
|
uploader "AttachmentUploader"
|
|
|
|
end
|
2017-06-07 23:32:38 -04:00
|
|
|
end
|
|
|
|
end
|