Sha256: ceeb11bdb6002075bb04cd580c3b9c9b13e914a74af5bfa091f0cfff78e07e7d

Contents?: true

Size: 906 Bytes

Versions: 1

Compression:

Stored size: 906 Bytes

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

  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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
intercom-3.0.4 spec/unit/intercom/contact_spec.rb