spec/unit/intercom/contact_spec.rb in intercom-4.1.3 vs spec/unit/intercom/contact_spec.rb in intercom-4.2.0

- old
+ new

@@ -258,10 +258,16 @@ contact = Intercom::Contact.new('id' => '1') client.expects(:post).with('/contacts/1/unarchive', {}) client.contacts.unarchive(contact) end + it 'deletes an archived contact' do + contact = Intercom::Contact.new('id' => '1','archived' =>true) + client.expects(:delete).with('/contacts/1', {}) + client.contacts.delete_archived_contact("1") + end + describe 'merging' do let(:lead) { Intercom::Contact.from_api(external_id: 'contact_id', role: 'lead') } let(:user) { Intercom::Contact.from_api(id: 'external_id', role: 'user') } it 'should be successful with a lead and user' do @@ -274,10 +280,11 @@ describe 'nested resources' do let(:contact) { Intercom::Contact.new(id: '1', client: client) } let(:contact_no_tags) { Intercom::Contact.new(id: '2', client: client, tags: []) } let(:company) { Intercom::Company.new(id: '1') } + let(:subscription) { Intercom::Subscription.new(id: '1', client: client) } let(:tag) { Intercom::Tag.new(id: '1') } let(:note) { Intercom::Note.new(body: "<p>Text for the note</p>") } it 'returns a collection proxy for listing notes' do proxy = contact.notes @@ -336,10 +343,15 @@ it 'adds a tag to a contact' do client.expects(:post).with('/contacts/1/tags', "id": tag.id).returns(tag.to_hash) contact.add_tag({ "id": tag.id }) end + it 'removes a subscription to a contact' do + client.expects(:delete).with("/contacts/1/subscriptions/#{subscription.id}", "id": subscription.id).returns(subscription.to_hash) + contact.remove_subscription_type({ "id": subscription.id }) + end + it 'removes a tag from a contact' do client.expects(:delete).with("/contacts/1/tags/#{tag.id}", "id": tag.id ).returns(tag.to_hash) contact.remove_tag({ "id": tag.id }) end @@ -383,9 +395,14 @@ end it 'adds a note to a contact' do client.expects(:post).with('/contacts/1/notes', {body: note.body}).returns(note.to_hash) contact.create_note({body: note.body}) + end + + it 'adds a subscription to a contact' do + client.expects(:post).with('/contacts/1/subscriptions', "id": subscription.id).returns(subscription.to_hash) + contact.create_subscription_type({ "id": subscription.id }) end it 'adds a tag to a contact' do client.expects(:post).with('/contacts/1/tags', "id": tag.id).returns(tag.to_hash) contact.add_tag({ "id": tag.id })