Sha256: 0b78ce22000daf0261c901076138ac8e2b61747a0eb3ea5094975db7bd44cea6
Contents?: true
Size: 1.77 KB
Versions: 15
Compression:
Stored size: 1.77 KB
Contents
require "spec_helper" describe "Intercom::Contact" do let (:client) { Intercom::Client.new(app_id: 'app_id', api_key: 'api_key') } it 'should be listable' do proxy = client.contacts.all proxy.resource_name.must_equal 'contacts' proxy.finder_url.must_equal '/contacts' proxy.resource_class.must_equal Intercom::Contact end it 'should not throw ArgumentErrors when there are no parameters' do client.expects(:post) client.contacts.create end it 'can update a contact with an id' do contact = Intercom::Contact.new(:id => "de45ae78gae1289cb") client.expects(:put).with("/contacts/de45ae78gae1289cb", {'custom_attributes' => {}}) client.contacts.save(contact) end describe 'converting' do let(:contact) { Intercom::Contact.from_api(user_id: 'contact_id') } let(:user) { Intercom::User.from_api(id: 'user_id') } it do client.expects(:post).with( "/contacts/convert", { contact: { user_id: contact.user_id }, user: { 'id' => user.id } } ).returns(test_user) client.contacts.convert(contact, user) end end it "returns a ClientCollectionProxy for all without making any requests" do client.expects(:execute_request).never all = client.contacts.all all.must_be_instance_of(Intercom::ClientCollectionProxy) end it "deletes a contact" do contact = Intercom::Contact.new("id" => "1") client.expects(:delete).with("/contacts/1", {}).returns(contact) client.contacts.delete(contact) end it "sends a request for a hard deletion" do contact = Intercom::Contact.new("id" => "1") client.expects(:post).with("/user_delete_requests", {intercom_user_id: "1"}).returns({id: contact.id}) client.contacts.request_hard_delete(contact) end end
Version data entries
15 entries across 15 versions & 1 rubygems