Sha256: c35e3870d5957aefce533b231df59d45568575f84a2c2cfe3cf3b088d4b678f5

Contents?: true

Size: 1.19 KB

Versions: 8

Compression:

Stored size: 1.19 KB

Contents

require "test_helper"

module Fogged
  class ResourcesControllerConfirmTest < ActionController::TestCase
    tests ResourcesController
    include ResourceTestHelper

    test "should confirm resource" do
      resource = fogged_resources(:resource_png_1)

      put :confirm, :id => resource

      assert_json_resource(resource.reload)
      assert_equal 800, resource.width
      assert_equal 600, resource.height
      refute resource.encoding?
    end

    test "should confirm video resource with zencoder enabled" do
      in_a_fork do
        require "zencoder"
        Fogged.configure

        Zencoder::Job.expects(:create).returns(
          OpenStruct.new(:body => create_output)
        )
        resource = fogged_resources(:resource_mov_1)

        put :confirm, :id => resource

        assert_json_resource(resource.reload)
        assert resource.encoding_job_id
        assert resource.encoding?
      end
    end

    test "should not confirm resource with invalid id" do
      assert_raise(ActiveRecord::RecordNotFound) do
        put :confirm, :id => 123456
      end
    end

    private

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fogged-0.0.13 test/controllers/fogged/resources_controller/confirm_test.rb
fogged-0.0.12 test/controllers/fogged/resources_controller/confirm_test.rb
fogged-0.0.11 test/controllers/fogged/resources_controller/confirm_test.rb
fogged-0.0.10 test/controllers/fogged/resources_controller/confirm_test.rb
fogged-0.0.9 test/controllers/fogged/resources_controller/confirm_test.rb
fogged-0.0.8 test/controllers/fogged/resources_controller/confirm_test.rb
fogged-0.0.7 test/controllers/fogged/resources_controller/confirm_test.rb
fogged-0.0.6 test/controllers/fogged/resources_controller/confirm_test.rb