Sha256: 73d0c2d648df7679e6cb040ebaa9057b4d8efc11d2962e1d9185b337241e3f09

Contents?: true

Size: 1.15 KB

Versions: 23

Compression:

Stored size: 1.15 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
    end
  end
end

Version data entries

23 entries across 23 versions & 3 rubygems

Version Path
xero_gateway-float-2.1.7 test/unit/organisation_test.rb
xero_gateway-float-2.1.6 test/unit/organisation_test.rb
xero_gateway-float-2.1.4 test/unit/organisation_test.rb
xero_gateway-float-2.1.3 test/unit/organisation_test.rb
xero_gateway-float-2.1.1 test/unit/organisation_test.rb
xero_gateway-float-2.0.18 test/unit/organisation_test.rb
xero_gateway-float-2.0.17 test/unit/organisation_test.rb
xero_gateway-float-2.0.16 test/unit/organisation_test.rb
xero_gateway-float-2.0.15 test/unit/organisation_test.rb
xero_gateway-2.1.0 test/unit/organisation_test.rb
xero_gateway-n8vision-2.0.20 test/unit/organisation_test.rb
xero_gateway-2.0.19 test/unit/organisation_test.rb
xero_gateway-2.0.18 test/unit/organisation_test.rb
xero_gateway-2.0.17 test/unit/organisation_test.rb
xero_gateway-2.0.16 test/unit/organisation_test.rb
xero_gateway-2.0.15 test/unit/organisation_test.rb
xero_gateway-2.0.14 test/unit/organisation_test.rb
xero_gateway-2.0.13 test/unit/organisation_test.rb
xero_gateway-2.0.12 test/unit/organisation_test.rb
xero_gateway-2.0.11 test/unit/organisation_test.rb