Sha256: d05599864082fd94b3420d998c2c2c9df64fb213e5d348fb940c296c0067115e

Contents?: true

Size: 1.78 KB

Versions: 7

Compression:

Stored size: 1.78 KB

Contents

require "spec_helper"

describe Bugsnag::Api::Client::CurrentUser do
  before do
    Bugsnag::Api.reset!
  end

  describe ".list_organizations", :vcr do
    context "when using user credentials" do
      it "returns users organizations" do
        client = basic_auth_client
        organizations = client.organizations
        expect(organizations).to be_kind_of(Array)
        expect(organizations.first.name).not_to be_nil

        assert_requested :get, bugsnag_url("/user/organizations")
      end
    end
    context "when using auth token" do
      it "returns the organization the auth token belongs to" do
        client = auth_token_client
        organizations = client.organizations
        expect(organizations).to be_kind_of(Array)
        expect(organizations.length).to eq(1)
        expect(organizations.first.name).not_to be_nil

        assert_requested :get, bugsnag_url("/user/organizations")
      end
    end
  end

  describe ".list_projects", :vcr do
    context "when using auth token" do
      it "lists current user's projects in the organization" do
        client = auth_token_client
        org_id = test_bugsnag_org_id
        projects = client.projects org_id
        expect(projects).to be_kind_of(Array)
        expect(projects.first.name).not_to be_nil

        assert_requested :get, bugsnag_url("/organizations/#{org_id}/projects")
      end
    end

    context "when using user credentials" do
      it "lists current user's projects in the organization" do
        client = basic_auth_client
        org_id = test_bugsnag_org_id
        projects = client.projects org_id
        expect(projects).to be_kind_of(Array)
        expect(projects.first.name).not_to be_nil

        assert_requested :get, bugsnag_url("/organizations/#{org_id}/projects")
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
bugsnag-api-3.0.0 spec/bugsnag/api/client/currentuser_spec.rb
bugsnag-api-2.1.1 spec/bugsnag/api/client/currentuser_spec.rb
bugsnag-api-2.1.0 spec/bugsnag/api/client/currentuser_spec.rb
bugsnag-api-2.0.3 spec/bugsnag/api/client/currentuser_spec.rb
bugsnag-api-2.0.2 spec/bugsnag/api/client/currentuser_spec.rb
bugsnag-api-2.0.1 spec/bugsnag/api/client/currentuser_spec.rb
bugsnag-api-2.0.0 spec/bugsnag/api/client/currentuser_spec.rb