|
311 | 311 | client.expects(:delete).with("/contacts/1/companies/#{company.id}", "id": tag.id ).returns(test_company)
|
312 | 312 | contact.remove_company({ "id": tag.id })
|
313 | 313 | end
|
| 314 | + |
| 315 | + describe 'just after creating the contact' do |
| 316 | + let(:contact) do |
| 317 | + contact = Intercom:: Contact.new('email' => '[email protected]', :external_id => 'i-1224242') |
| 318 | + client.expects(:post).with('/contacts', 'email' => '[email protected]', 'external_id' => 'i-1224242', 'custom_attributes' => {}) |
| 319 | + .returns('id' => 1, 'email' => '[email protected]', 'external_id' => 'i-1224242') |
| 320 | + client.contacts.save(contact) |
| 321 | + end |
| 322 | + |
| 323 | + it 'returns a collection proxy for listing notes' do |
| 324 | + proxy = contact.notes |
| 325 | + _(proxy.resource_name).must_equal 'notes' |
| 326 | + _(proxy.url).must_equal '/contacts/1/notes' |
| 327 | + _(proxy.resource_class).must_equal Intercom::Note |
| 328 | + end |
| 329 | + |
| 330 | + it 'returns a collection proxy for listing tags' do |
| 331 | + proxy = contact.tags |
| 332 | + _(proxy.resource_name).must_equal 'tags' |
| 333 | + _(proxy.url).must_equal '/contacts/1/tags' |
| 334 | + _(proxy.resource_class).must_equal Intercom::Tag |
| 335 | + end |
| 336 | + |
| 337 | + it 'returns a collection proxy for listing companies' do |
| 338 | + proxy = contact.companies |
| 339 | + _(proxy.resource_name).must_equal 'companies' |
| 340 | + _(proxy.url).must_equal '/contacts/1/companies' |
| 341 | + _(proxy.resource_class).must_equal Intercom::Company |
| 342 | + end |
| 343 | + |
| 344 | + it 'adds a note to a contact' do |
| 345 | + client.expects(:post).with('/contacts/1/notes', {body: note.body}).returns(note.to_hash) |
| 346 | + contact.create_note({body: note.body}) |
| 347 | + end |
| 348 | + |
| 349 | + it 'adds a tag to a contact' do |
| 350 | + client.expects(:post).with('/contacts/1/tags', "id": tag.id).returns(tag.to_hash) |
| 351 | + contact.add_tag({ "id": tag.id }) |
| 352 | + end |
| 353 | + |
| 354 | + it 'removes a tag from a contact' do |
| 355 | + client.expects(:delete).with("/contacts/1/tags/#{tag.id}", "id": tag.id ).returns(tag.to_hash) |
| 356 | + contact.remove_tag({ "id": tag.id }) |
| 357 | + end |
| 358 | + |
| 359 | + it 'adds a contact to a company' do |
| 360 | + client.expects(:post).with('/contacts/1/companies', "id": company.id).returns(test_company) |
| 361 | + contact.add_company({ "id": tag.id }) |
| 362 | + end |
| 363 | + |
| 364 | + it 'removes a contact from a company' do |
| 365 | + client.expects(:delete).with("/contacts/1/companies/#{company.id}", "id": tag.id ).returns(test_company) |
| 366 | + contact.remove_company({ "id": tag.id }) |
| 367 | + end |
| 368 | + end |
314 | 369 | end
|
315 | 370 | end
|
0 commit comments