Sha256: 9072dc67a0f55b1e4d2b4f92a2016b704b9b01b4b5c88c3a71e3a56e3d500c83

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 KB

Contents

require "test_helper"

module Fogged
  module Resources
    class AWSEncoderTest < ActiveSupport::TestCase
      def setup
        super
        @resource = fogged_resources(:resource_mov)
        @encoder = AWSEncoder.new(@resource)
      end

      test "should encode video file" do
        in_a_fork do
          require "zencoder"
          require "delayed_job_active_record"

          Zencoder::Job.expects(:create).returns(
            OpenStruct.new(:body => create_output)
          )
          assert_difference("Delayed::Job.count") do
            @encoder.encode!
          end

          assert @resource.encoding?
          assert_equal 0, @resource.encoding_progress
          assert_equal "1234567890", @resource.encoding_job_id
        end
      end

      test "should not encode image file" do
        in_a_fork do
          require "delayed_job_active_record"

          @resource = fogged_resources(:resource_png)
          @encoder = AWSEncoder.new(@resource)

          assert_no_difference("Delayed::Job.count") do
            @encoder.encode!
          end
          refute @resource.encoding?
          refute @resource.encoding_job_id
        end
      end

      private

      def create_output
        {
          :id => 1234567890
        }.with_indifferent_access
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fogged-0.0.4 test/models/fogged/resources/aws_encoder_test.rb
fogged-0.0.3 test/models/fogged/resources/aws_encoder_test.rb
fogged-0.0.2 test/models/fogged/resources/aws_encoder_test.rb