Sha256: 9c69b1e0b7d8b44b4a7a905d94c19e5ce96a403832ea5c55baa723b505e45495

Contents?: true

Size: 1.84 KB

Versions: 31

Compression:

Stored size: 1.84 KB

Contents

require File.dirname(__FILE__) + '/../test_helper'

class GetCreditNoteTest < Test::Unit::TestCase
  include TestHelper
  
  def setup
    @gateway = XeroGateway::Gateway.new(CONSUMER_KEY, CONSUMER_SECRET)
    
    if STUB_XERO_CALLS
      @gateway.xero_url = "DUMMY_URL"
      
      @gateway.stubs(:http_get).with {|client, url, params| url =~ /CreditNotes(\/[0-9a-z\-]+)?$/i }.returns(get_file_as_string("credit_note.xml"))              
      @gateway.stubs(:http_put).with {|client, url, body, params| url =~ /CreditNotes$/ }.returns(get_file_as_string("create_credit_note.xml"))          
    end
  end
  
  def test_get_credit_note
    # Make sure there is an credit_note in Xero to retrieve
    credit_note = @gateway.create_credit_note(dummy_credit_note).credit_note

    result = @gateway.get_credit_note(credit_note.credit_note_id)
    assert result.success?
    assert !result.request_params.nil?
    assert !result.response_xml.nil?    
    assert_equal result.credit_note.credit_note_number, credit_note.credit_note_number

    result = @gateway.get_credit_note(credit_note.credit_note_number)
    assert result.success?
    assert !result.request_params.nil?
    assert !result.response_xml.nil?    
    assert_equal result.credit_note.credit_note_id, credit_note.credit_note_id
  end
  
  def test_line_items_downloaded_set_correctly
    # Make sure there is an credit_note in Xero to retrieve.
    example_credit_note = @gateway.create_credit_note(dummy_credit_note).credit_note
    
    # No line items.
    response = @gateway.get_credit_note(example_credit_note.credit_note_id)
    assert_equal(true, response.success?)
    
    credit_note = response.credit_note
    assert_kind_of(XeroGateway::LineItem, credit_note.line_items.first)
    assert_kind_of(XeroGateway::CreditNote, credit_note)
    assert_equal(true, credit_note.line_items_downloaded?)
  end
  
end

Version data entries

31 entries across 31 versions & 3 rubygems

Version Path
xero_gateway-2.7.0 test/integration/get_credit_note_test.rb
xero_gateway-2.6.0 test/integration/get_credit_note_test.rb
xero_gateway-2.5.0 test/integration/get_credit_note_test.rb
xero_gateway-2.4.0 test/integration/get_credit_note_test.rb
xero_gateway-2.3.0 test/integration/get_credit_note_test.rb
xero_gateway-float-2.1.7 test/integration/get_credit_note_test.rb
xero_gateway-float-2.1.6 test/integration/get_credit_note_test.rb
xero_gateway-float-2.1.4 test/integration/get_credit_note_test.rb
xero_gateway-float-2.1.3 test/integration/get_credit_note_test.rb
xero_gateway-float-2.1.1 test/integration/get_credit_note_test.rb
xero_gateway-float-2.0.18 test/integration/get_credit_note_test.rb
xero_gateway-float-2.0.17 test/integration/get_credit_note_test.rb
xero_gateway-float-2.0.16 test/integration/get_credit_note_test.rb
xero_gateway-float-2.0.15 test/integration/get_credit_note_test.rb
xero_gateway-2.1.0 test/integration/get_credit_note_test.rb
xero_gateway-n8vision-2.0.20 test/integration/get_credit_note_test.rb
xero_gateway-2.0.19 test/integration/get_credit_note_test.rb
xero_gateway-2.0.18 test/integration/get_credit_note_test.rb
xero_gateway-2.0.17 test/integration/get_credit_note_test.rb
xero_gateway-2.0.16 test/integration/get_credit_note_test.rb