Sha256: 88331b46eca1acbc7c2a4edaf20e54d92719c789bcb344841ddf6b269cc5d8ba

Contents?: true

Size: 1.45 KB

Versions: 10

Compression:

Stored size: 1.45 KB

Contents

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

      attachment_on_s3 { File.open(Engine.root.join('spec', 'fixtures', 'video.mp4')) }
      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 :on_filesystem do
        attachment_on_filesystem { File.open(Engine.root.join('spec', 'fixtures', 'video.mp4')) }
        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', 'video.mp4')) }
        attachment_on_s3 { nil }
        state { 'uploading_to_s3_failed' }
      end

      trait :waiting_for_confirmation do
        state { 'waiting_for_confirmation' }
      end

      trait :encoding_failed do
        state { 'encoding_failed' }
      end

      trait :encoded do
      end

      trait :with_highdef_encoding do
        association :entry, :with_highdef_video_encoding
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

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