Sha256: d1721e84f713fe222f212788ed7fc8ab1842fc404a5fd50950af6c3ec7a0b9c5

Contents?: true

Size: 1.2 KB

Versions: 8

Compression:

Stored size: 1.2 KB

Contents

require 'spec_helper'

describe "Intercom::Tag" do
  let (:client) { Intercom::Client.new(app_id: 'app_id',  api_key: 'api_key') }

  it "gets a tag" do
    client.expects(:get).with("/tags", {:name => "Test Tag"}).returns(test_tag)
    tag = client.tags.find(:name => "Test Tag")
    tag.name.must_equal "Test Tag"
  end

  it "creates a tag" do
    client.expects(:post).with("/tags", {'name' => "Test Tag"}).returns(test_tag)
    tag = client.tags.create(:name => "Test Tag")
    tag.name.must_equal "Test Tag"
  end

  it "tags users" do
    client.expects(:post).with("/tags", {'name' => "Test Tag", 'users' => [ { user_id: 'abc123' }, { user_id: 'def456' } ], 'tag_or_untag' => 'tag'}).returns(test_tag)
    tag = client.tags.tag(:name => "Test Tag", :users => [ { user_id: "abc123" }, { user_id: "def456" } ] )
    tag.name.must_equal "Test Tag"
    tag.tagged_user_count.must_equal 2
  end

  it 'untags users' do
    client.expects(:post).with("/tags", {'name' => "Test Tag", 'users' => [ { user_id: 'abc123', untag: true }, { user_id: 'def456', untag: true } ], 'tag_or_untag' => 'untag'}).returns(test_tag)
    client.tags.untag(:name => "Test Tag", :users => [ { user_id: "abc123" }, { user_id: "def456" } ])
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
intercom-3.4.0 spec/unit/intercom/tag_spec.rb
intercom-3.3.0 spec/unit/intercom/tag_spec.rb
intercom-3.2.0 spec/unit/intercom/tag_spec.rb
intercom-3.1.0 spec/unit/intercom/tag_spec.rb
intercom-3.0.6 spec/unit/intercom/tag_spec.rb
intercom-3.0.5 spec/unit/intercom/tag_spec.rb
intercom-3.0.4 spec/unit/intercom/tag_spec.rb
intercom-3.0.3 spec/unit/intercom/tag_spec.rb