Sha256: 859c30247ac5526d04175badad1a510ea5e6d009b759e1c5558a1f478e78c407

Contents?: true

Size: 1.35 KB

Versions: 34

Compression:

Stored size: 1.35 KB

Contents

require File.dirname(__FILE__) + '/../test_helper'

class GetContactsTest < Test::Unit::TestCase
  include TestHelper
  
  def setup
    @gateway = XeroGateway::Gateway.new(CONSUMER_KEY, CONSUMER_SECRET)
    
    if STUB_XERO_CALLS
      @gateway.xero_url = "DUMMY_URL"
      
      @gateway.stubs(:http_get).with {|client, url, params| url =~ /Contacts$/ }.returns(get_file_as_string("contacts.xml"))          
      @gateway.stubs(:http_put).with {|client, url, body, params| url =~ /Contacts$/ }.returns(get_file_as_string("contact.xml"))          
    end
  end
  
  def test_get_contacts
    # Make sure there is an contact in Xero to retrieve
    contact = @gateway.create_contact(dummy_contact).contact
    flunk "get_contacts could not be tested because create_contact failed" if contact.nil?

    result = @gateway.get_contacts
    assert result.success?
    assert !result.request_params.nil?
    assert !result.response_xml.nil?
    assert result.contacts.collect {|c| c.contact_id}.include?(contact.contact_id)
  end  
  
  # Make sure that a reference to gateway is passed when the get_contacts response is parsed.
  def test_get_contacts_gateway_reference
    result = @gateway.get_contacts
    assert(result.success?)
    assert_not_equal(0, result.contacts.size)
    
    result.contacts.each do | contact |
      assert(contact.gateway === @gateway)
    end
  end
  
end

Version data entries

34 entries across 34 versions & 3 rubygems

Version Path
xero_gateway-2.7.0 test/integration/get_contacts_test.rb
xero_gateway-2.6.0 test/integration/get_contacts_test.rb
xero_gateway-2.5.0 test/integration/get_contacts_test.rb
xero_gateway-2.4.0 test/integration/get_contacts_test.rb
xero_gateway-2.3.0 test/integration/get_contacts_test.rb
xero_gateway-float-2.1.7 test/integration/get_contacts_test.rb
xero_gateway-float-2.1.6 test/integration/get_contacts_test.rb
xero_gateway-float-2.1.4 test/integration/get_contacts_test.rb
xero_gateway-float-2.1.3 test/integration/get_contacts_test.rb
xero_gateway-float-2.1.1 test/integration/get_contacts_test.rb
xero_gateway-float-2.0.18 test/integration/get_contacts_test.rb
xero_gateway-float-2.0.17 test/integration/get_contacts_test.rb
xero_gateway-float-2.0.16 test/integration/get_contacts_test.rb
xero_gateway-float-2.0.15 test/integration/get_contacts_test.rb
xero_gateway-2.1.0 test/integration/get_contacts_test.rb
xero_gateway-n8vision-2.0.20 test/integration/get_contacts_test.rb
xero_gateway-2.0.19 test/integration/get_contacts_test.rb
xero_gateway-2.0.18 test/integration/get_contacts_test.rb
xero_gateway-2.0.17 test/integration/get_contacts_test.rb
xero_gateway-2.0.16 test/integration/get_contacts_test.rb