Sha256: 192380dd454a43dd4ac90b10290f548ce7953c2cb1731beba0079f7b2a2fbb17

Contents?: true

Size: 1.28 KB

Versions: 29

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

29 entries across 29 versions & 1 rubygems

Version Path
pageflow-17.0.4 spec/factories/image_files.rb
pageflow-17.0.3 spec/factories/image_files.rb
pageflow-17.0.2 spec/factories/image_files.rb
pageflow-17.0.1 spec/factories/image_files.rb
pageflow-17.0.0 spec/factories/image_files.rb
pageflow-16.2.0 spec/factories/image_files.rb
pageflow-16.1.0 spec/factories/image_files.rb
pageflow-16.0.0 spec/factories/image_files.rb
pageflow-15.8.0 spec/factories/image_files.rb
pageflow-15.7.1 spec/factories/image_files.rb
pageflow-15.7.0 spec/factories/image_files.rb
pageflow-15.6.1 spec/factories/image_files.rb
pageflow-15.6.0 spec/factories/image_files.rb
pageflow-15.5.0 spec/factories/image_files.rb
pageflow-15.4.0 spec/factories/image_files.rb
pageflow-15.3.0 spec/factories/image_files.rb
pageflow-15.2.2 spec/factories/image_files.rb
pageflow-15.2.1 spec/factories/image_files.rb
pageflow-15.2.0 spec/factories/image_files.rb
pageflow-15.1.2 spec/factories/image_files.rb