Sha256: 85128fb17d320526b7a7379e51d57c79a1139cabef04bfaddcc5f90609ba713f

Contents?: true

Size: 1.38 KB

Versions: 35

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'

describe Intercom::Company do
  let (:client) { Intercom::Client.new(app_id: 'app_id',  api_key: 'api_key') }

  describe 'when no response raises error' do
    it 'on find' do
      client.expects(:get).with("/companies", {:company_id => '4'}).returns(nil)
      proc {client.companies.find(:company_id => '4')}.must_raise Intercom::HttpError
    end

    it 'on find_all' do
      client.expects(:get).with("/companies", {}).returns(nil)
      proc {client.companies.all.each {|company| }}.must_raise Intercom::HttpError
    end

    it 'on load' do
      client.expects(:get).with("/companies", {:company_id => '4'}).returns({'type' =>'user', 'id' =>'aaaaaaaaaaaaaaaaaaaaaaaa', 'company_id' => '4', 'name' => 'MyCo'})
      company = client.companies.find(:company_id => '4')
      client.expects(:get).with('/companies/aaaaaaaaaaaaaaaaaaaaaaaa', {}).returns(nil)
      proc {client.companies.load(company)}.must_raise Intercom::HttpError
    end
  end

  it 'gets users in a company' do
    client.expects(:get).with("/companies/abc123/users", {}).returns(page_of_users(false))
    client.companies.users('abc123').each do |u|
    end
  end

  it 'finds a company' do
    client.expects(:get).with("/companies/531ee472cce572a6ec000006", {}).returns(test_company)
    company = client.companies.find(id: '531ee472cce572a6ec000006')
    company.name.must_equal("Blue Sun")
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
intercom-3.5.4 spec/unit/intercom/company_spec.rb
intercom-3.5.3 spec/unit/intercom/company_spec.rb
intercom-3.5.2 spec/unit/intercom/company_spec.rb
intercom-3.5.1 spec/unit/intercom/company_spec.rb
intercom-3.4.0 spec/unit/intercom/company_spec.rb
intercom-3.3.0 spec/unit/intercom/company_spec.rb
intercom-3.2.0 spec/unit/intercom/company_spec.rb
intercom-3.1.0 spec/unit/intercom/company_spec.rb
intercom-3.0.6 spec/unit/intercom/company_spec.rb
intercom-3.0.5 spec/unit/intercom/company_spec.rb
intercom-3.0.4 spec/unit/intercom/company_spec.rb
intercom-3.0.3 spec/unit/intercom/company_spec.rb
intercom-3.0.2 spec/unit/intercom/company_spec.rb
intercom-3.0.0 spec/unit/intercom/company_spec.rb
intercom-3.0.0b1 spec/unit/intercom/company_spec.rb