Sha256: 83cbde4f357a02d30fbd444a790a7f7e93ac557c17b0d03fc14d9d36afdcbe44

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

require 'test_helper'

class CreditNoteTest < Test::Unit::TestCase
  include TestHelper
  
  def setup
    @client = Xeroizer::PublicApplication.new(CONSUMER_KEY, CONSUMER_SECRET)    
    mock_api("CreditNotes")
    @credit_note = @client.CreditNote.first
  end
  
  context "credit note totals" do
    
    should "raise error when trying to set totals directly" do
      assert_raises Xeroizer::SettingTotalDirectlyNotSupported do
        @credit_note.sub_total = 500.0
      end
      assert_raises Xeroizer::SettingTotalDirectlyNotSupported do
        @credit_note.total_tax = 50.0
      end
      assert_raises Xeroizer::SettingTotalDirectlyNotSupported do
        @credit_note.total = 550.0
      end
    end
        
    should "large-scale testing from API XML" do
      credit_notes = @client.CreditNote.all
      credit_notes.each do | credit_note |
        assert_equal(credit_note.attributes[:currency_code], credit_note.currency_code)

        if credit_note.attributes[:currency_rate]
          assert_equal(credit_note.attributes[:currency_rate], credit_note.currency_rate)
        else
          assert_equal(1.0, credit_note.currency_rate)
        end


        assert_equal(credit_note.attributes[:sub_total], credit_note.sub_total)
        assert_equal(credit_note.attributes[:total_tax], credit_note.total_tax)
        assert_equal(credit_note.attributes[:total], credit_note.total)
      end
    end
    
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xeroizer-float-2.15.3.14 test/unit/models/credit_note_test.rb