Sha256: 55ccf807ed393f56c080e236adba66f462600035cfb3462d0196a2ed0ba74b9f

Contents?: true

Size: 944 Bytes

Versions: 9

Compression:

Stored size: 944 Bytes

Contents

module ResourceTestHelper
  extend ActiveSupport::Concern
  include JsonTestHelper

  included do
    setup do
      @routes = Fogged::Engine.routes
    end
  end

  private

  def assert_json_resource(resource)
    assert_json_resources([resource], :resource)
  end

  def assert_json_resources(resources, json_key = :resources)
    assert_response :success
    json = response_json[json_key]
    assert_json_objects(resources, json, :id, :url, :name)
    resources.zip([json].flatten).each do |resource, json_resource|
      if json_resource[:upload_url]
        assert_equal resource.upload_url.chop, json_resource[:upload_url].chop
      end

      if resource.video?
        [:h264_url, :mpeg_url, :webm_url, :thumbnail_urls].each do |field|
          assert_equal resource.send(field), json_resource[field]
        end
        assert_equal((resource.encoding_progress || 0), json_resource[:encoding_progress])
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
fogged-0.0.13 test/controllers/concerns/resource_test_helper.rb
fogged-0.0.12 test/controllers/concerns/resource_test_helper.rb
fogged-0.0.11 test/controllers/concerns/resource_test_helper.rb
fogged-0.0.10 test/controllers/concerns/resource_test_helper.rb
fogged-0.0.9 test/controllers/concerns/resource_test_helper.rb
fogged-0.0.8 test/controllers/concerns/resource_test_helper.rb
fogged-0.0.7 test/controllers/concerns/resource_test_helper.rb
fogged-0.0.6 test/controllers/concerns/resource_test_helper.rb
fogged-0.0.5 test/controllers/concerns/resource_test_helper.rb