Sha256: 0eb0b5f8acdc2232c240d3a036bc2c7310022a75e663661b25121fc66162b3ae

Contents?: true

Size: 1.46 KB

Versions: 4

Compression:

Stored size: 1.46 KB

Contents

require_relative './spec_helper'

describe "Add Subtitle" do
  context "when user is unauthenticated" do
    it_behaves_like "Unauthenticated", ->(api) do
      api.add_subtitle(test_video_id("user1"), body: "x", language: "en")
    end
  end

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

    context "RW token" do
      context "when params are valid" do
        before(:all) do
          @res = @api.add_subtitle(test_video_id("user1"), body: "SRT", language: "en")
        end

        it_behaves_like "202 Accepted"
      end

      context "when language param is blank" do
        before(:all) do
          @res = @api.add_subtitle(test_video_id("user1"), body: "SRT", language: "")
        end

        it_behaves_like "422 Failure"

        specify { expect(@res.errors.first["language"]).to eq("empty string") }
      end
    end


    context "RO token" do
      it_behaves_like "RO only", user1["login"], user1["ro_token"], ->(api) do
        api.add_subtitle(test_video_id("user1"), body: "SRT", language: "en")
      end
    end

    context "when user doesn't have permission to the video" do
      before(:all) do
        @res = @api.add_subtitle(test_video_id("user2"), body: "SRT", language: "en")
      end

      it_behaves_like "422 Failure"

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vzaar-1.6.2 examples/add_subtitle_spec.rb
vzaar-1.6.1 examples/add_subtitle_spec.rb
vzaar-1.6.0 examples/add_subtitle_spec.rb
vzaar-1.5.3 examples/add_subtitle_spec.rb