Sha256: f1bc178ae368df17109580419f311e651725734f8bbb78f73d6a41504a6df065

Contents?: true

Size: 1.62 KB

Versions: 8

Compression:

Stored size: 1.62 KB

Contents

require "spec_helper"

describe "Intercom::DataAttribute" do
  let(:client) { Intercom::Client.new(token: 'token') }

  it "returns a CollectionProxy for all without making any requests" do
    client.expects(:execute_request).never
    all = client.data_attributes.all
    _(all).must_be_instance_of(Intercom::ClientCollectionProxy)
  end


  it "creates a new data attribute" do
    client.expects(:post).with("/data_attributes", { "name" => "blah", "model" => "contact", "data_type" => "string" }).returns(status: 200)
    client.data_attributes.create("name": "blah",
                                  "model": "contact",
                                  "data_type": "string" )
  end

  it "updates an existing attribute" do
    attribute = Intercom::DataAttribute.new("id": 123,
                                            "name": "blah",
                                            "model": "contact",
                                            "data_type": "string")
    client.expects(:put).with("/data_attributes/#{attribute.id}", { "name" => "New name", "model" => "contact", "data_type" => "string" })
    attribute.name = "New name"
    client.data_attributes.save(attribute)
    _(attribute.name).must_equal "New name"
  end

  it 'gets a list of attributes' do
    client.expects(:get).with("/data_attributes", {}).returns(test_data_attribute_list)
    client.data_attributes.all.each { |d| }
  end

  it 'finds all customer or company attributes' do
    client.expects(:get).with("/data_attributes", { "model": "contact" }).returns(test_data_attribute_list)
    client.data_attributes.find_all({"model": "contact"}).each { |d| }
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
intercom-4.2.1 spec/unit/intercom/data_attribute_spec.rb
intercom-4.2.0 spec/unit/intercom/data_attribute_spec.rb
intercom-4.1.3 spec/unit/intercom/data_attribute_spec.rb
intercom-4.1.2 spec/unit/intercom/data_attribute_spec.rb
intercom-4.1.1 spec/unit/intercom/data_attribute_spec.rb
intercom-4.1.0 spec/unit/intercom/data_attribute_spec.rb
intercom-4.0.1 spec/unit/intercom/data_attribute_spec.rb
intercom-4.0.0 spec/unit/intercom/data_attribute_spec.rb