Sha256: 0905bd24699f835b479194444d29471753f90fecba18eeb338a041ef19226643

Contents?: true

Size: 1.5 KB

Versions: 1

Compression:

Stored size: 1.5 KB

Contents

require 'unit_test_helper'

class OrganisationTest < Test::Unit::TestCase
  include TestHelper

  def setup
    @client = Xeroizer::PublicApplication.new(CONSUMER_KEY, CONSUMER_SECRET)
  end

  context "sales_tax_basis_validations" do
    should "allow nil sales tax bases and countries" do
      organisation = @client.Organisation.build

      assert(organisation.valid?)
    end

    it 'should validate sales_tax_basis' do
      organisation = @client.Organisation.build(:sales_tax_basis => "Cat")

      assert(!organisation.valid?)

      organisation.sales_tax_basis = "ACCRUALS"

      assert(organisation.valid?)
    end

    it 'should validate sales_tax_basis for a specific country like NZ' do
      organisation = @client.Organisation.build(:sales_tax_basis => "FLATRATECASH", :country_code => "NZ")

      assert(!organisation.valid?)

      organisation.sales_tax_basis = "NONE"

      assert(organisation.valid?)
    end
  end

  context "parse response" do
    it "includes payment_terms" do
      @instance = Xeroizer::Record::OrganisationModel.new(nil, "Organisation")
      some_xml = get_record_xml("organisations")

      result = @instance.parse_response(some_xml)
      organisation = result.response_items.first

      assert_equal(organisation.payment_terms.bills.day, "4")
      assert_equal(organisation.payment_terms.bills.type, "OFFOLLOWINGMONTH")
      assert_equal(organisation.payment_terms.sales.day, "2")
      assert_equal(organisation.payment_terms.sales.type, "OFFOLLOWINGMONTH")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xeroizer-3-pre-beta-3.0.0.pre.beta test/unit/models/organisation_test.rb