test/unit/models/invoice_test.rb in xeroizer-2.20.0 vs test/unit/models/invoice_test.rb in xeroizer-3.0.0

- old
+ new

@@ -1,12 +1,12 @@ -require 'test_helper' +require 'unit_test_helper' class InvoiceTest < Test::Unit::TestCase include TestHelper - + def setup - @client = Xeroizer::PublicApplication.new(CONSUMER_KEY, CONSUMER_SECRET) + @client = Xeroizer::OAuth2Application.new(CLIENT_ID, CLIENT_SECRET) mock_api('Invoices') @invoice = @client.Invoice.first end def build_valid_authorised_invoice @@ -24,44 +24,44 @@ }] }) 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 "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 - + context "invoice validations" do should "build an invalid invoice if there are no attributes" do assert_equal(false, @client.Invoice.build.valid?) end should "build a valid DRAFT invoice with minimal attributes" do - invoice = @client.Invoice.build :type => "ACCREC", :contact => { :name => "ABC Limited" } + invoice = @client.Invoice.build :type => "ACCREC", :date => Date.today, :contact => { :name => "ABC Limited" } assert_equal(true, invoice.valid?) end should "build a invalid AUTHORISED invoice with minimal attributes" do invoice = @client.Invoice.build :type => "ACCREC", :contact => { :name => "ABC Limited" }, :status => "AUTHORISED" @@ -103,25 +103,25 @@ end end context "contact shortcuts" do - + should "have valid #contact_name and #contact_id without downloading full invoice" do invoices = @client.Invoice.all invoices.each do |invoice| assert_not_equal("", invoice.contact_name) assert_not_equal("", invoice.contact_id) assert_equal(false, invoice.complete_record_downloaded?) end end - + end context "updated date" do should "get the updated date as utc" do invoices = @client.Invoice.all - + assert_equal(Time.parse("2008-9-16T10:28:51.5Z"), invoices[0].updated_date_utc) invoices.each do |invoice| assert invoice.updated_date_utc.utc?, "updated_date_utc should be utc" end