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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

76 lines
1.9 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
FactoryBot.define do
2017-08-17 22:00:37 +05:30
factory :upload do
2021-01-29 00:20:46 +05:30
model { association(:project) }
2018-12-05 23:21:45 +05:30
size { 100.kilobytes }
2019-12-21 20:55:43 +05:30
uploader { "AvatarUploader" }
mount_point { :avatar }
secret { nil }
store { ObjectStorage::Store::LOCAL }
2018-03-17 18:26:18 +05:30
# we should build a mount agnostic upload by default
transient do
2019-12-21 20:55:43 +05:30
filename { 'avatar.jpg' }
2018-03-17 18:26:18 +05:30
end
2019-12-21 20:55:43 +05:30
path do
uploader_instance = Object.const_get(uploader.to_s, false).new(model, mount_point)
File.join(uploader_instance.store_dir, filename)
end
2018-03-17 18:26:18 +05:30
trait :personal_snippet_upload do
2021-01-29 00:20:46 +05:30
model { association(:personal_snippet) }
2018-03-17 18:26:18 +05:30
path { File.join(secret, filename) }
2019-12-21 20:55:43 +05:30
uploader { "PersonalFileUploader" }
2018-12-05 23:21:45 +05:30
secret { SecureRandom.hex }
2019-12-21 20:55:43 +05:30
mount_point { nil }
2018-03-17 18:26:18 +05:30
end
trait :issuable_upload do
2019-12-21 20:55:43 +05:30
uploader { "FileUploader" }
2018-03-17 18:26:18 +05:30
path { File.join(secret, filename) }
2018-12-05 23:21:45 +05:30
secret { SecureRandom.hex }
2019-12-21 20:55:43 +05:30
mount_point { nil }
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
2019-12-21 20:55:43 +05:30
store { ObjectStorage::Store::REMOTE }
2018-05-09 12:01:36 +05:30
end
2018-03-17 18:26:18 +05:30
trait :namespace_upload do
2021-01-29 00:20:46 +05:30
model { association(:group) }
2018-03-17 18:26:18 +05:30
path { File.join(secret, filename) }
2019-12-21 20:55:43 +05:30
uploader { "NamespaceFileUploader" }
2018-12-05 23:21:45 +05:30
secret { SecureRandom.hex }
2019-12-21 20:55:43 +05:30
mount_point { nil }
2018-03-17 18:26:18 +05:30
end
2018-11-20 20:47:30 +05:30
trait :favicon_upload do
2021-01-29 00:20:46 +05:30
model { association(:appearance) }
2019-12-21 20:55:43 +05:30
uploader { "FaviconUploader" }
2018-12-05 23:21:45 +05:30
secret { SecureRandom.hex }
2019-12-21 20:55:43 +05:30
mount_point { :favicon }
2018-11-20 20:47:30 +05:30
end
2018-03-17 18:26:18 +05:30
trait :attachment_upload do
2019-12-21 20:55:43 +05:30
mount_point { :attachment }
2021-01-29 00:20:46 +05:30
model { association(:note) }
2019-12-21 20:55:43 +05:30
uploader { "AttachmentUploader" }
2018-03-17 18:26:18 +05:30
end
2020-05-24 23:13:21 +05:30
trait :design_action_image_v432x230_upload do
mount_point { :image_v432x230 }
2021-01-29 00:20:46 +05:30
model { association(:design_action) }
2020-05-24 23:13:21 +05:30
uploader { ::DesignManagement::DesignV432x230Uploader.name }
end
2017-08-17 22:00:37 +05:30
end
end