Sha256: 60c22dd188f6fedf80bf81a0674d3aa5cd80c2f62316b4d001558b3234655747

Contents?: true

Size: 1.97 KB

Versions: 8

Compression:

Stored size: 1.97 KB

Contents

require "test_helper"

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

    setup do
      @resource = fogged_resources(:resource_mov_3)
      @resource.update!(:encoding_job_id => 1234565434567890)
    end

    test "should receive zencoder notification" do
      refute @resource.encoding_progress
      refute @resource.width
      refute @resource.height
      refute @resource.duration

      post :zencoder_notification, payload(@resource.encoding_job_id)

      assert @resource.reload.encoding_progress
      assert @resource.width
      assert @resource.height
      assert @resource.duration
    end

    test "should receive zencoder notification with invalid id" do
      post :zencoder_notification, payload("foobar!")
    end

    test "should receive zencoder notification with invalid payload" do
      refute @resource.encoding_progress
      refute @resource.width
      refute @resource.height
      refute @resource.duration

      post :zencoder_notification,
           payload(@resource.encoding_job_id).except(:outputs)

      refute @resource.reload.encoding_progress
      refute @resource.width
      refute @resource.height
      refute @resource.duration
    end

    test "should receive zencoder notification with failed job" do
      refute @resource.encoding_progress
      refute @resource.width
      refute @resource.height
      refute @resource.duration

      post :zencoder_notification, payload(@resource.encoding_job_id, "failed")

      refute @resource.reload.encoding_progress
      refute @resource.width
      refute @resource.height
      refute @resource.duration
    end

    private

    def payload(encoding_job_id, state = "finished")
      {
        :job => {
          :id => encoding_job_id,
          :state => state
        },
        :outputs => [
          { :duration_in_ms => 85600, :height => 480, :width => 640 }
        ]
      }
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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