Sha256: 0630a1e097bd922f734472aa71520e8da64874068906b8af9c2138c5ae9610d3

Contents?: true

Size: 1.46 KB

Versions: 11

Compression:

Stored size: 1.46 KB

Contents

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

class InvoiceTest < Test::Unit::TestCase
  include TestHelper
  
  def setup
    @client = Xeroizer::PublicApplication.new(CONSUMER_KEY, CONSUMER_SECRET)
    mock_api('Invoices')
    @invoice = @client.Invoice.first
  end
  
  context "invoice types" do
    
    should "have helpers to determine invoice type" do
      @invoice.type = 'ACCREC'
      assert_equal(true, @invoice.accounts_receivable?)
      assert_equal(false, @invoice.accounts_payable?)

      @invoice.type = 'ACCPAY'
      assert_equal(false, @invoice.accounts_receivable?)
      assert_equal(true, @invoice.accounts_payable?)
    end
    
  end
  
  context "invoice totals" do
    
    should "raise error when trying to set totals directly" do
      assert_raises Xeroizer::SettingTotalDirectlyNotSupported do
        @invoice.sub_total = 100.0
      end
      assert_raises Xeroizer::SettingTotalDirectlyNotSupported do
        @invoice.total_tax = 100.0
      end
      assert_raises Xeroizer::SettingTotalDirectlyNotSupported do
        @invoice.total = 100.0
      end
    end
        
    should "large-scale testing from API XML" do
      invoices = @client.Invoice.all
      invoices.each do | invoice |
        assert_equal(invoice.attributes[:sub_total], invoice.sub_total)
        assert_equal(invoice.attributes[:total_tax], invoice.total_tax)
        assert_equal(invoice.attributes[:total], invoice.total)
      end
    end
    
  end
  
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
xeroizer-0.3.4 test/unit/models/invoice_test.rb
xeroizer-0.3.3 test/unit/models/invoice_test.rb
xeroizer-0.3.2 test/unit/models/invoice_test.rb
xeroizer-0.3.1 test/unit/models/invoice_test.rb
xeroizer-0.3.0 test/unit/models/invoice_test.rb
xeroizer-0.2.2 test/unit/models/invoice_test.rb
xeroizer-0.2.1 test/unit/models/invoice_test.rb
xeroizer-0.2.0 test/unit/models/invoice_test.rb
xeroizer-0.1.3 test/unit/models/invoice_test.rb
xeroizer-0.1.2 test/unit/models/invoice_test.rb
xeroizer-0.1.0 test/unit/models/invoice_test.rb