Sha256: 43f3ad1a66f424d12eea0a816b49e7c13fe74494bf813da3a6c04655d3061c05

Contents?: true

Size: 1.28 KB

Versions: 4

Compression:

Stored size: 1.28 KB

Contents

require_relative './spec_helper'

describe "Upload Thumbnail" do
  file_path = "./spec/support/pic.jpg"

  context "when user is unauthenticated" do
    it_behaves_like "Unauthenticated", ->(api) do
      api.upload_thumbnail(test_video_id("user1"), path: file_path)
    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.upload_thumbnail(test_video_id("user1"), path: file_path)
        end

        it_behaves_like "202 Accepted"
      end
    end

    context "RO token" do
      it_behaves_like "RO only", user1["login"], user1["ro_token"], ->(api) do
        api.upload_thumbnail(test_video_id("user1"), path: file_path)
      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.upload_thumbnail(test_video_id("user2"), path: file_path)
      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/upload_thumbnail_spec.rb
vzaar-1.6.1 examples/upload_thumbnail_spec.rb
vzaar-1.6.0 examples/upload_thumbnail_spec.rb
vzaar-1.5.3 examples/upload_thumbnail_spec.rb