Welcome to mirror list, hosted at ThFree Co, Russian Federation.

uploads.rb « factories « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b45f6f30e4063f6fc02c497570549f1c42127fcb (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
FactoryBot.define do
  factory :upload do
    model { build(: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 'myfile.jpg'
    end

    # this needs to comply with RecordsUpload::Concern#upload_path
    path { File.join("uploads/-/system", model.class.to_s.underscore, mount_point.to_s, 'avatar.jpg') }

    trait :personal_snippet_upload do
      uploader "PersonalFileUploader"
      path { File.join(secret, filename) }
      model { build(:personal_snippet) }
      secret SecureRandom.hex
    end

    trait :issuable_upload do
      uploader "FileUploader"
      path { File.join(secret, filename) }
      secret SecureRandom.hex
    end

    trait :object_storage do
      store ObjectStorage::Store::REMOTE
    end

    trait :namespace_upload do
      model { build(:group) }
      path { File.join(secret, filename) }
      uploader "NamespaceFileUploader"
      secret SecureRandom.hex
    end

    trait :attachment_upload do
      transient do
        mount_point :attachment
      end

      model { build(:note) }
      uploader "AttachmentUploader"
    end
  end
end