Sha256: 65019ccb0ecaadcd28e48f38db3713aef661e25205874349a7d97523583c9026

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

require File.join(File.dirname(__FILE__), '../test_helper.rb')

class OrganisationTest < Test::Unit::TestCase
  
  # Tests that an organisation can be converted into XML that Xero can understand, and then converted back to an organisation
  def test_build_and_parse_xml
    org = create_test_organisation
    
    # Generate the XML message
    org_as_xml = org.to_xml

    # Parse the XML message and retrieve the account element
    org_element = REXML::XPath.first(REXML::Document.new(org_as_xml), "/Organisation")

    # Build a new account from the XML
    result_org = XeroGateway::Organisation.from_xml(org_element)
    
    # Check the account details
    assert_equal org, result_org
  end
  
  
  private
  
  def create_test_organisation
    XeroGateway::Organisation.new.tap do |org|
      org.name                = "Demo Company (NZ)"
      org.legal_name          = "Demo Company (NZ)"
      org.pays_tax            = true
      org.version             = "NZ"
      org.base_currency       = "NZD"
      org.country_code        = "NZ"
      org.organisation_type   = nil
      org.organisation_status = nil
      org.is_demo_company     = false
      org.line_of_business = "Graphic Design & Web Development"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xero_gateway-2.3.0 test/unit/organisation_test.rb