Sha256: 3e880b76b9f971fc7e937a2fa6f7174a25a23e14fe88fd9e292b1874fdcb7443
Contents?: true
Size: 1.64 KB
Versions: 18
Compression:
Stored size: 1.64 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 by intercom ID" do client.expects(:get).with("/companies/abc123/users", {}).returns(page_of_users(false)) client.companies.users_by_intercom_company_id("abc123").each { |u| } end it "gets users in a company by external company ID" do client.expects(:get).with("/companies", { company_id: "abc123", type: "user" }).returns(page_of_users(false)) client.companies.users_by_company_id("abc123").each { |u| } 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
18 entries across 18 versions & 1 rubygems