debian-mirror-gitlab/spec/factories/uploads.rb

66 lines
1.6 KiB
Ruby
Raw Normal View History

2018-03-17 18:26:18 +05:30
FactoryBot.define do
2017-08-17 22:00:37 +05:30
factory :upload do
model { build(:project) }
2018-12-05 23:21:45 +05:30
size { 100.kilobytes }
2017-08-17 22:00:37 +05:30
uploader "AvatarUploader"
2018-03-17 18:26:18 +05:30
mount_point :avatar
secret nil
2018-05-09 12:01:36 +05:30
store ObjectStorage::Store::LOCAL
2018-03-17 18:26:18 +05:30
# we should build a mount agnostic upload by default
transient do
filename 'myfile.jpg'
end
# this needs to comply with RecordsUpload::Concern#upload_path
2019-09-04 21:01:54 +05:30
path { File.join("uploads/-/system", model.class.underscore, mount_point.to_s, 'avatar.jpg') }
2018-03-17 18:26:18 +05:30
trait :personal_snippet_upload do
uploader "PersonalFileUploader"
path { File.join(secret, filename) }
model { build(:personal_snippet) }
2018-12-05 23:21:45 +05:30
secret { SecureRandom.hex }
2018-03-17 18:26:18 +05:30
end
trait :issuable_upload do
uploader "FileUploader"
path { File.join(secret, filename) }
2018-12-05 23:21:45 +05:30
secret { SecureRandom.hex }
2018-03-17 18:26:18 +05:30
end
2018-11-08 19:23:39 +05:30
trait :with_file do
after(:create) do |upload|
FileUtils.mkdir_p(File.dirname(upload.absolute_path))
FileUtils.touch(upload.absolute_path)
end
end
2018-05-09 12:01:36 +05:30
trait :object_storage do
store ObjectStorage::Store::REMOTE
end
2018-03-17 18:26:18 +05:30
trait :namespace_upload do
model { build(:group) }
path { File.join(secret, filename) }
uploader "NamespaceFileUploader"
2018-12-05 23:21:45 +05:30
secret { SecureRandom.hex }
2018-03-17 18:26:18 +05:30
end
2018-11-20 20:47:30 +05:30
trait :favicon_upload do
model { build(:appearance) }
path { File.join(secret, filename) }
uploader "FaviconUploader"
2018-12-05 23:21:45 +05:30
secret { SecureRandom.hex }
2018-11-20 20:47:30 +05:30
end
2018-03-17 18:26:18 +05:30
trait :attachment_upload do
transient do
mount_point :attachment
end
model { build(:note) }
uploader "AttachmentUploader"
end
2017-08-17 22:00:37 +05:30
end
end