mirror of
https://gitlab.com/gitlab-org/gitlab-foss.git
synced 2025-08-01 16:04:19 +00:00
25 lines
579 B
Ruby
25 lines
579 B
Ruby
# frozen_string_literal: true
|
|
|
|
FactoryBot.define do
|
|
factory :file_uploader do
|
|
skip_create
|
|
|
|
secret { nil }
|
|
|
|
transient do
|
|
fixture { 'rails_sample.jpg' }
|
|
path { File.join(Rails.root, 'spec/fixtures', fixture) }
|
|
file { Rack::Test::UploadedFile.new(path) }
|
|
end
|
|
|
|
after(:build) do |uploader, evaluator|
|
|
uploader.store!(evaluator.file) if evaluator.model&.persisted?
|
|
end
|
|
|
|
initialize_with do
|
|
klass = container.is_a?(Group) ? NamespaceFileUploader : FileUploader
|
|
klass.new(container, nil, secret: secret)
|
|
end
|
|
end
|
|
end
|