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

- old
+ new

@@ -272,10 +272,11 @@ end end 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(: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 @@ -295,9 +296,30 @@ it 'returns a collection proxy for listing tags' do proxy = contact.tags _(proxy.resource_name).must_equal 'tags' _(proxy.url).must_equal '/contacts/1/tags' _(proxy.resource_class).must_equal Intercom::Tag + end + + it 'returns correct tags from differring contacts' do + client.expects(:get).with('/contacts/1/tags', {}).returns({ + 'type' => 'tag.list', + 'tags' => [ + { + 'type' => 'tag', + 'id' => '1', + 'name' => 'VIP Customer' + }, + { + 'type' => 'tag', + 'id' => '2', + 'name' => 'Test tag' + } + ] + }) + + _(contact_no_tags.tags.map{ |t| t.id }).must_equal [] + _(contact.tags.map{ |t| t.id }).must_equal ['1', '2'] end it 'returns a collection proxy for listing companies' do proxy = contact.companies _(proxy.resource_name).must_equal 'companies'