Sha256: b34a594d560dc4561d3ac31bf66619810db268863f067faea269e609afb2e28a

Contents?: true

Size: 1.64 KB

Versions: 7

Compression:

Stored size: 1.64 KB

Contents

require_relative './spec_helper'

describe "Generate Thumbnail" do
  before(:all) do
    @video_id = test_video_id("user1")
    @video_id2 = test_video_id("user2")
  end

  context "when user is unauthenticated" do
    it_behaves_like "Unauthenticated", -> (api) do
      api.generate_thumbnail(test_video_id("user1"), time: 3)
    end
  end

  context "Authenticated User" do
    context "RW token" do
      before(:all) do
        @api = _api(login: user1["login"],
                    application_token: user1["rw_token"])
      end

      context "when params are valid" do
        before(:all) do
          @res = @api.generate_thumbnail(test_video_id("user1"), time: 3)
        end

        it_behaves_like "202 Accepted"
      end

      context "when time param is invalid" do
        before(:all) do
          @res = @api.generate_thumbnail(test_video_id("user1"), time: "invalid")
        end

        it_behaves_like "422 Failure"

        specify do
          expect(@res.errors.first["thumb_time"]).to eq("invalid integer")
        end
      end
    end


    context "RO token" do
      it_behaves_like "RO only", user1["login"], user1["ro_token"], -> (api) do
        api.generate_thumbnail(test_video_id("user1"), time: 3)
      end
    end


    context "when user doesn't have permission to the video" do
      before(:all) do
        api = _api(login: user1["login"],
                   application_token: user1["rw_token"])
        @res = api.generate_thumbnail(test_video_id("user2"), time: 3)
      end

      it_behaves_like "422 Failure"

      specify do
        expect(@res.errors.first["user"]).to match(/Permission Denied/)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
vzaar-1.5.2 examples/generate_thumbnail_spec.rb
vzaar-1.5.1 examples/generate_thumbnail_spec.rb
vzaar-1.5.0 examples/generate_thumbnail_spec.rb
vzaar-1.4.4 examples/generate_thumbnail_spec.rb
vzaar-1.4.1 examples/generate_thumbnail_spec.rb
vzaar-1.3.1 examples/generate_thumbnail_spec.rb
vzaar-1.3.0 examples/generate_thumbnail_spec.rb