Sha256: dfd12d6675af21a46778f37154b2c5064273bf35846f82e2945103963d2e4386

Contents?: true

Size: 915 Bytes

Versions: 8

Compression:

Stored size: 915 Bytes

Contents

module Pageflow
  FactoryBot.define do
    factory :hosted_file, class: 'Pageflow::TestHostedFile' do
      attachment_on_s3 { File.open(Engine.root.join('spec', 'fixtures', 'image.png')) }
      state { 'uploaded_to_s3' }

      transient do
        used_in { nil }
      end

      after(:create) do |file, evaluator|
        create(:file_usage, file: file, revision: evaluator.used_in) if evaluator.used_in
      end

      trait :on_filesystem do
        attachment_on_filesystem { File.open(Engine.root.join('spec', 'fixtures', 'image.png')) }
        attachment_on_s3 { nil }
        state { 'not_uploaded_to_s3' }
      end

      trait :uploading_to_s3_failed do
        attachment_on_filesystem { File.open(Engine.root.join('spec', 'fixtures', 'image.png')) }
        attachment_on_s3 { nil }
        state { 'uploading_to_s3_failed' }
      end

      trait :uploaded_to_s3 do
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pageflow-13.6.0 spec/factories/hosted_files.rb
pageflow-13.5.0 spec/factories/hosted_files.rb
pageflow-13.4.0 spec/factories/hosted_files.rb
pageflow-13.3.0 spec/factories/hosted_files.rb
pageflow-13.2.0 spec/factories/hosted_files.rb
pageflow-13.1.0 spec/factories/hosted_files.rb
pageflow-13.0.0 spec/factories/hosted_files.rb
pageflow-13.0.0.rc1 spec/factories/hosted_files.rb