blob: a060cd7d6f8fbe4be734d942769c465db97b7268 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# frozen_string_literal: true
FactoryBot.define do
factory :upload do
model { create(:project) }
size { 100.kilobytes }
uploader { "AvatarUploader" }
mount_point { :avatar }
secret { nil }
store { ObjectStorage::Store::LOCAL }
# we should build a mount agnostic upload by default
transient do
filename { 'avatar.jpg' }
end
path do
uploader_instance = Object.const_get(uploader.to_s, false).new(model, mount_point)
File.join(uploader_instance.store_dir, filename)
end
trait :personal_snippet_upload do
model { create(:personal_snippet) }
path { File.join(secret, filename) }
uploader { "PersonalFileUploader" }
secret { SecureRandom.hex }
mount_point { nil }
end
trait :issuable_upload do
uploader { "FileUploader" }
path { File.join(secret, filename) }
secret { SecureRandom.hex }
mount_point { nil }
end
trait :with_file do
after(:create) do |upload|
FileUtils.mkdir_p(File.dirname(upload.absolute_path))
FileUtils.touch(upload.absolute_path)
end
end
trait :object_storage do
store { ObjectStorage::Store::REMOTE }
end
trait :namespace_upload do
model { create(:group) }
path { File.join(secret, filename) }
uploader { "NamespaceFileUploader" }
secret { SecureRandom.hex }
mount_point { nil }
end
trait :favicon_upload do
model { create(:appearance) }
uploader { "FaviconUploader" }
secret { SecureRandom.hex }
mount_point { :favicon }
end
trait :attachment_upload do
mount_point { :attachment }
model { create(:note) }
uploader { "AttachmentUploader" }
end
end
end
|