Sha256: 28e2114696eac50fafa0e144775f07310772fba5cbb30fd505f3b06c603a3708

Contents?: true

Size: 1.39 KB

Versions: 43

Compression:

Stored size: 1.39 KB

Contents

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

      attachment { File.open(Engine.root.join('spec', 'fixtures', 'et.ogg')) }
      state { 'encoded' }

      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 { 'et.ogg' }
        state { 'uploading' }

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

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

      trait :uploading_failed do
        state { 'uploading_failed' }
      end

      trait :waiting_for_confirmation do
        state { 'waiting_for_confirmation' }
      end

      trait :fetching_meta_data_failed do
        state { 'fetching_meta_data_failed' }
      end

      trait :encoding_failed do
        state { 'encoding_failed' }
      end

      trait :encoded do
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

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