Sha256: 7b570337788df86d4d06242ebd90f575ce7043fdc35ecd38a5135b4b03084b1d

Contents?: true

Size: 1.77 KB

Versions: 2

Compression:

Stored size: 1.77 KB

Contents

require 'helper'

describe Bearcat::Client::Accounts do
  before do
    @client = Bearcat::Client.new(prefix: "http://canvas.instructure.com", token: "test_token")
  end

  it 'returns a list of all the accounts the user belongs to' do
    stub_get(@client, "/api/v1/accounts").to_return(json_response("accounts.json"))
    accounts = @client.list_accounts
    accounts.count.should == 1
    accounts.first['name'].should == 'Local Testing'
  end

  it 'returns a list of all of the accounts admins' do
    stub_get(@client, "/api/v1/accounts/1/admins").to_return(json_response("account_admins.json"))
    account_admins = @client.account_admins(1)
    account_admins.count.should == 4
    account_admins.first['id'].should == 3
    account_admins.last['role'].should == 'Custom Admin'
  end

  it "returns a single account" do
    stub_get(@client, "/api/v1/accounts/1").to_return(json_response("single_account.json"))
    account = @client.account(1)
    account["id"].should == 1
    account["name"].should == "Local Testing"
  end

  it "returns enrollment terms for an account" do
    stub_get(@client, "/api/v1/accounts/1/terms").to_return(json_response("enrollment_terms.json"))
    account = @client.terms(1)
    terms = account.members
    terms.count.should == 1
    terms.first['id'].should == 4
    terms.first['name'].should == 'Term 1'
  end

  it "returns the roles for an account" do
    stub_get(@client, "/api/v1/accounts/1/roles").to_return(json_response("account_roles.json"))
    account = @client.account_roles(1)
    roles  = account.members 
    roles.count.should == 1
    roles.first['id'].should == 1
    roles.first['role'].should == 'AccountAdmin'
    roles.first['permissions'].count.should == 4
    roles.first['permissions']['manage_catalog']['enabled'].should == true
  end 

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bearcat-1.0.23 spec/bearcat/client/accounts_spec.rb
bearcat-1.0.22 spec/bearcat/client/accounts_spec.rb