Sha256: 941525539c6ffd484970df754303ef8ce1f938b4e91d39643955f4b02f16599d

Contents?: true

Size: 1.28 KB

Versions: 14

Compression:

Stored size: 1.28 KB

Contents

module Pageflow
  FactoryBot.define do
    factory :image_file, :class => ImageFile do
      entry
      uploader { create(:user) }

      attachment { File.open(Engine.root.join('spec', 'fixtures', 'image.jpg')) }
      state { 'processed' }

      transient do
        used_in { nil }
        with_configuration { nil }
      end

      before(:create) do |file, evaluator|
        file.entry = evaluator.used_in.entry if evaluator.used_in
      end

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

      trait :uploading do
        attachment { nil }
        file_name { 'image.jpg' }
        state { 'uploading' }

        after :create do |image_file|
          simulate_direct_upload(image_file)
        end
      end

      trait :uploaded do
        uploading
        state { 'uploaded' }
      end

      trait :uploading_failed do
        state { 'uploading_failed' }
      end

      trait :processing do
        state { 'processing' }
      end

      trait :processed do
      end

      trait :processing_failed do
        state { 'processing_failed' }
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
pageflow-14.5.2 spec/factories/image_files.rb
pageflow-15.0.2 spec/factories/image_files.rb
pageflow-15.0.1 spec/factories/image_files.rb
pageflow-15.0.0 spec/factories/image_files.rb
pageflow-14.5.1 spec/factories/image_files.rb
pageflow-14.5.0 spec/factories/image_files.rb
pageflow-15.0.0.rc2 spec/factories/image_files.rb
pageflow-15.0.0.rc1 spec/factories/image_files.rb
pageflow-15.0.0.beta4 spec/factories/image_files.rb
pageflow-15.0.0.beta3 spec/factories/image_files.rb
pageflow-14.4.0 spec/factories/image_files.rb
pageflow-15.0.0.beta2 spec/factories/image_files.rb
pageflow-15.0.0.beta1 spec/factories/image_files.rb
pageflow-14.3.0 spec/factories/image_files.rb