summaryrefslogtreecommitdiff
path: root/spec/factories/file_uploaders.rb
blob: dc888fdd535f9ffbdffc255941067df35b957ef7 (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
# frozen_string_literal: true

FactoryBot.define do
  factory :file_uploader do
    skip_create

    project
    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)
    end

    initialize_with do
      new(project, secret)
    end
  end
end