xero_gateway-n8vision 2.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. data/Gemfile +12 -0
  2. data/LICENSE +14 -0
  3. data/README.textile +357 -0
  4. data/Rakefile +14 -0
  5. data/examples/oauth.rb +25 -0
  6. data/examples/partner_app.rb +36 -0
  7. data/init.rb +1 -0
  8. data/lib/oauth/oauth_consumer.rb +14 -0
  9. data/lib/xero_gateway.rb +41 -0
  10. data/lib/xero_gateway/account.rb +86 -0
  11. data/lib/xero_gateway/accounts_list.rb +73 -0
  12. data/lib/xero_gateway/address.rb +96 -0
  13. data/lib/xero_gateway/bank_transaction.rb +175 -0
  14. data/lib/xero_gateway/ca-certificates.crt +2560 -0
  15. data/lib/xero_gateway/contact.rb +203 -0
  16. data/lib/xero_gateway/credit_note.rb +220 -0
  17. data/lib/xero_gateway/currency.rb +56 -0
  18. data/lib/xero_gateway/dates.rb +25 -0
  19. data/lib/xero_gateway/error.rb +18 -0
  20. data/lib/xero_gateway/exceptions.rb +51 -0
  21. data/lib/xero_gateway/gateway.rb +698 -0
  22. data/lib/xero_gateway/http.rb +135 -0
  23. data/lib/xero_gateway/http_encoding_helper.rb +49 -0
  24. data/lib/xero_gateway/invoice.rb +238 -0
  25. data/lib/xero_gateway/journal_line.rb +102 -0
  26. data/lib/xero_gateway/line_item.rb +125 -0
  27. data/lib/xero_gateway/line_item_calculations.rb +51 -0
  28. data/lib/xero_gateway/manual_journal.rb +163 -0
  29. data/lib/xero_gateway/money.rb +16 -0
  30. data/lib/xero_gateway/oauth.rb +92 -0
  31. data/lib/xero_gateway/organisation.rb +75 -0
  32. data/lib/xero_gateway/partner_app.rb +30 -0
  33. data/lib/xero_gateway/payment.rb +43 -0
  34. data/lib/xero_gateway/phone.rb +77 -0
  35. data/lib/xero_gateway/private_app.rb +17 -0
  36. data/lib/xero_gateway/response.rb +43 -0
  37. data/lib/xero_gateway/tax_rate.rb +63 -0
  38. data/lib/xero_gateway/tracking_category.rb +87 -0
  39. data/test/integration/accounts_list_test.rb +109 -0
  40. data/test/integration/create_bank_transaction_test.rb +38 -0
  41. data/test/integration/create_contact_test.rb +66 -0
  42. data/test/integration/create_credit_note_test.rb +49 -0
  43. data/test/integration/create_invoice_test.rb +49 -0
  44. data/test/integration/create_manual_journal_test.rb +35 -0
  45. data/test/integration/get_accounts_test.rb +23 -0
  46. data/test/integration/get_bank_transaction_test.rb +51 -0
  47. data/test/integration/get_bank_transactions_test.rb +88 -0
  48. data/test/integration/get_contact_test.rb +28 -0
  49. data/test/integration/get_contacts_test.rb +40 -0
  50. data/test/integration/get_credit_note_test.rb +48 -0
  51. data/test/integration/get_credit_notes_test.rb +90 -0
  52. data/test/integration/get_currencies_test.rb +25 -0
  53. data/test/integration/get_invoice_test.rb +48 -0
  54. data/test/integration/get_invoices_test.rb +92 -0
  55. data/test/integration/get_manual_journal_test.rb +50 -0
  56. data/test/integration/get_manual_journals_test.rb +88 -0
  57. data/test/integration/get_organisation_test.rb +24 -0
  58. data/test/integration/get_tax_rates_test.rb +25 -0
  59. data/test/integration/get_tracking_categories_test.rb +27 -0
  60. data/test/integration/update_bank_transaction_test.rb +31 -0
  61. data/test/integration/update_contact_test.rb +31 -0
  62. data/test/integration/update_invoice_test.rb +31 -0
  63. data/test/integration/update_manual_journal_test.rb +31 -0
  64. data/test/test_helper.rb +217 -0
  65. data/test/unit/account_test.rb +47 -0
  66. data/test/unit/bank_transaction_test.rb +126 -0
  67. data/test/unit/contact_test.rb +97 -0
  68. data/test/unit/credit_note_test.rb +284 -0
  69. data/test/unit/currency_test.rb +31 -0
  70. data/test/unit/gateway_test.rb +119 -0
  71. data/test/unit/invoice_test.rb +326 -0
  72. data/test/unit/manual_journal_test.rb +93 -0
  73. data/test/unit/oauth_test.rb +116 -0
  74. data/test/unit/organisation_test.rb +38 -0
  75. data/test/unit/tax_rate_test.rb +38 -0
  76. data/test/unit/tracking_category_test.rb +52 -0
  77. data/xero_gateway-n8vision.gemspec +15 -0
  78. metadata +178 -0
@@ -0,0 +1,48 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class GetCreditNoteTest < Test::Unit::TestCase
4
+ include TestHelper
5
+
6
+ def setup
7
+ @gateway = XeroGateway::Gateway.new(CONSUMER_KEY, CONSUMER_SECRET)
8
+
9
+ if STUB_XERO_CALLS
10
+ @gateway.xero_url = "DUMMY_URL"
11
+
12
+ @gateway.stubs(:http_get).with {|client, url, params| url =~ /CreditNotes(\/[0-9a-z\-]+)?$/i }.returns(get_file_as_string("credit_note.xml"))
13
+ @gateway.stubs(:http_put).with {|client, url, body, params| url =~ /CreditNotes$/ }.returns(get_file_as_string("create_credit_note.xml"))
14
+ end
15
+ end
16
+
17
+ def test_get_credit_note
18
+ # Make sure there is an credit_note in Xero to retrieve
19
+ credit_note = @gateway.create_credit_note(dummy_credit_note).credit_note
20
+
21
+ result = @gateway.get_credit_note(credit_note.credit_note_id)
22
+ assert result.success?
23
+ assert !result.request_params.nil?
24
+ assert !result.response_xml.nil?
25
+ assert_equal result.credit_note.credit_note_number, credit_note.credit_note_number
26
+
27
+ result = @gateway.get_credit_note(credit_note.credit_note_number)
28
+ assert result.success?
29
+ assert !result.request_params.nil?
30
+ assert !result.response_xml.nil?
31
+ assert_equal result.credit_note.credit_note_id, credit_note.credit_note_id
32
+ end
33
+
34
+ def test_line_items_downloaded_set_correctly
35
+ # Make sure there is an credit_note in Xero to retrieve.
36
+ example_credit_note = @gateway.create_credit_note(dummy_credit_note).credit_note
37
+
38
+ # No line items.
39
+ response = @gateway.get_credit_note(example_credit_note.credit_note_id)
40
+ assert_equal(true, response.success?)
41
+
42
+ credit_note = response.credit_note
43
+ assert_kind_of(XeroGateway::LineItem, credit_note.line_items.first)
44
+ assert_kind_of(XeroGateway::CreditNote, credit_note)
45
+ assert_equal(true, credit_note.line_items_downloaded?)
46
+ end
47
+
48
+ end
@@ -0,0 +1,90 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class GetCreditNotesTest < Test::Unit::TestCase
4
+ include TestHelper
5
+
6
+ INVALID_CREDIT_NOTE_ID = "99999999-9999-9999-9999-999999999999" unless defined?(INVALID_CREDIT_NOTE_ID)
7
+
8
+ def setup
9
+ @gateway = XeroGateway::Gateway.new(CONSUMER_KEY, CONSUMER_SECRET)
10
+
11
+ if STUB_XERO_CALLS
12
+ @gateway.xero_url = "DUMMY_URL"
13
+
14
+ @gateway.stubs(:http_get).with {|client, url, params| url =~ /CreditNotes/ }.returns(get_file_as_string("credit_notes.xml"))
15
+ @gateway.stubs(:http_put).with {|client, url, body, params| url =~ /CreditNotes$/ }.returns(get_file_as_string("create_credit_note.xml"))
16
+
17
+ # Get an credit_note with an invalid ID number.
18
+ @gateway.stubs(:http_get).with {|client, url, params| url =~ Regexp.new("CreditNotes/#{INVALID_CREDIT_NOTE_ID}") }.returns(get_file_as_string("credit_note_not_found_error.xml"))
19
+ end
20
+ end
21
+
22
+ def test_get_credit_notes
23
+ # Make sure there is an credit_note in Xero to retrieve
24
+ credit_note = @gateway.create_credit_note(dummy_credit_note).credit_note
25
+
26
+ result = @gateway.get_credit_notes
27
+ assert result.success?
28
+ assert !result.request_params.nil?
29
+ assert !result.response_xml.nil?
30
+ assert result.credit_notes.collect {|i| i.credit_note_number}.include?(credit_note.credit_note_number)
31
+ end
32
+
33
+ def test_get_credit_notes_with_modified_since_date
34
+ # Create a test credit_note
35
+ credit_note = dummy_credit_note
36
+ @gateway.create_credit_note(credit_note)
37
+
38
+ # Check that it is returned
39
+ result = @gateway.get_credit_notes(:modified_since => Date.today - 1)
40
+ assert result.success?
41
+ assert !result.request_params.nil?
42
+ assert !result.response_xml.nil?
43
+ assert result.request_params.keys.include?(:ModifiedAfter) # make sure the flag was sent
44
+ assert result.credit_notes.collect {|response_credit_note| response_credit_note.credit_note_number}.include?(credit_note.credit_note_number)
45
+ end
46
+
47
+ def test_line_items_downloaded_set_correctly
48
+ # No line items.
49
+ response = @gateway.get_credit_notes
50
+ assert_equal(true, response.success?)
51
+
52
+ credit_note = response.credit_notes.first
53
+ assert_kind_of(XeroGateway::CreditNote, credit_note)
54
+ assert_equal(false, credit_note.line_items_downloaded?)
55
+ end
56
+
57
+ # Make sure that a reference to gateway is passed when the get_credit_notes response is parsed.
58
+ def test_get_contacts_gateway_reference
59
+ result = @gateway.get_credit_notes
60
+ assert(result.success?)
61
+ assert_not_equal(0, result.credit_notes.size)
62
+
63
+ result.credit_notes.each do | credit_note |
64
+ assert(credit_note.gateway === @gateway)
65
+ end
66
+ end
67
+
68
+ # Test to make sure that we correctly error when an credit_note doesn't have an ID.
69
+ # This should usually never be ecountered, but might if a draft credit_note is deleted from Xero.
70
+ def test_to_ensure_that_an_credit_note_with_invalid_id_errors
71
+ # Make sure there is an credit_note to retrieve, even though we will mangle it later.
72
+ credit_note = @gateway.create_credit_note(dummy_credit_note).credit_note
73
+
74
+ result = @gateway.get_credit_notes
75
+ assert_equal(true, result.success?)
76
+
77
+ credit_note = result.credit_notes.first
78
+ assert_equal(false, credit_note.line_items_downloaded?)
79
+
80
+ # Mangle credit_note_id to invalid one.
81
+ credit_note.credit_note_id = INVALID_CREDIT_NOTE_ID
82
+
83
+ # Make sure we fail here.
84
+ line_items = nil
85
+ assert_raise(XeroGateway::CreditNoteNotFoundError) { line_items = credit_note.line_items }
86
+ assert_nil(line_items)
87
+
88
+ end
89
+
90
+ end
@@ -0,0 +1,25 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class GetCurrenciesTest < Test::Unit::TestCase
4
+ include TestHelper
5
+
6
+ def setup
7
+ @gateway = XeroGateway::Gateway.new(CONSUMER_KEY, CONSUMER_SECRET)
8
+
9
+ if STUB_XERO_CALLS
10
+ @gateway.xero_url = "DUMMY_URL"
11
+
12
+ @gateway.stubs(:http_get).with {|client, url, params| url =~ /Currencies$/ }.returns(get_file_as_string("currencies.xml"))
13
+ end
14
+ end
15
+
16
+ def test_get_currencies
17
+ result = @gateway.get_currencies
18
+ assert result.success?
19
+ assert !result.response_xml.nil?
20
+
21
+ assert result.currencies.size > 0
22
+ assert_equal XeroGateway::Currency, result.currencies.first.class
23
+ assert_equal "NZD", result.currencies.first.code
24
+ end
25
+ end
@@ -0,0 +1,48 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class GetInvoiceTest < Test::Unit::TestCase
4
+ include TestHelper
5
+
6
+ def setup
7
+ @gateway = XeroGateway::Gateway.new(CONSUMER_KEY, CONSUMER_SECRET)
8
+
9
+ if STUB_XERO_CALLS
10
+ @gateway.xero_url = "DUMMY_URL"
11
+
12
+ @gateway.stubs(:http_get).with {|client, url, params| url =~ /Invoices(\/[0-9a-z\-]+)?$/i }.returns(get_file_as_string("invoice.xml"))
13
+ @gateway.stubs(:http_put).with {|client, url, body, params| url =~ /Invoices$/ }.returns(get_file_as_string("create_invoice.xml"))
14
+ end
15
+ end
16
+
17
+ def test_get_invoice
18
+ # Make sure there is an invoice in Xero to retrieve
19
+ invoice = @gateway.create_invoice(dummy_invoice).invoice
20
+
21
+ result = @gateway.get_invoice(invoice.invoice_id)
22
+ assert result.success?
23
+ assert !result.request_params.nil?
24
+ assert !result.response_xml.nil?
25
+ assert_equal result.invoice.invoice_number, invoice.invoice_number
26
+
27
+ result = @gateway.get_invoice(invoice.invoice_number)
28
+ assert result.success?
29
+ assert !result.request_params.nil?
30
+ assert !result.response_xml.nil?
31
+ assert_equal result.invoice.invoice_id, invoice.invoice_id
32
+ end
33
+
34
+ def test_line_items_downloaded_set_correctly
35
+ # Make sure there is an invoice in Xero to retrieve.
36
+ example_invoice = @gateway.create_invoice(dummy_invoice).invoice
37
+
38
+ # No line items.
39
+ response = @gateway.get_invoice(example_invoice.invoice_id)
40
+ assert_equal(true, response.success?)
41
+
42
+ invoice = response.invoice
43
+ assert_kind_of(XeroGateway::LineItem, invoice.line_items.first)
44
+ assert_kind_of(XeroGateway::Invoice, invoice)
45
+ assert_equal(true, invoice.line_items_downloaded?)
46
+ end
47
+
48
+ end
@@ -0,0 +1,92 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class GetInvoicesTest < Test::Unit::TestCase
4
+ include TestHelper
5
+
6
+ INVALID_INVOICE_ID = "99999999-9999-9999-9999-999999999999" unless defined?(INVALID_INVOICE_ID)
7
+
8
+ def setup
9
+ @gateway = XeroGateway::Gateway.new(CONSUMER_KEY, CONSUMER_SECRET)
10
+
11
+ if STUB_XERO_CALLS
12
+ @gateway.xero_url = "DUMMY_URL"
13
+
14
+ @gateway.stubs(:http_get).with {|client, url, params| url =~ /Invoices/ }.returns(get_file_as_string("invoices.xml"))
15
+ @gateway.stubs(:http_put).with {|client, url, body, params| url =~ /Invoices$/ }.returns(get_file_as_string("create_invoice.xml"))
16
+
17
+ # Get an invoice with an invalid ID number.
18
+ @gateway.stubs(:http_get).with {|client, url, params| url =~ Regexp.new("Invoices/#{INVALID_INVOICE_ID}") }.returns(get_file_as_string("invoice_not_found_error.xml"))
19
+ end
20
+ end
21
+
22
+ def test_get_invoices
23
+ # Make sure there is an invoice in Xero to retrieve
24
+ invoice = @gateway.create_invoice(dummy_invoice).invoice
25
+
26
+ result = @gateway.get_invoices
27
+ assert result.success?
28
+ assert !result.request_params.nil?
29
+ assert !result.response_xml.nil?
30
+ assert result.invoices.collect {|i| i.invoice_number}.include?(invoice.invoice_number)
31
+ assert result.invoices[0].sent_to_contact == true
32
+ assert result.invoices[1].sent_to_contact == false
33
+ end
34
+
35
+ def test_get_invoices_with_modified_since_date
36
+ # Create a test invoice
37
+ invoice = dummy_invoice
38
+ @gateway.create_invoice(invoice)
39
+
40
+ # Check that it is returned
41
+ result = @gateway.get_invoices(:modified_since => Date.today - 1)
42
+ assert result.success?
43
+ assert !result.request_params.nil?
44
+ assert !result.response_xml.nil?
45
+ assert result.request_params.keys.include?(:ModifiedAfter) # make sure the flag was sent
46
+ assert result.invoices.collect {|response_invoice| response_invoice.invoice_number}.include?(invoice.invoice_number)
47
+ end
48
+
49
+ def test_line_items_downloaded_set_correctly
50
+ # No line items.
51
+ response = @gateway.get_invoices
52
+ assert_equal(true, response.success?)
53
+
54
+ invoice = response.invoices.first
55
+ assert_kind_of(XeroGateway::Invoice, invoice)
56
+ assert_equal(false, invoice.line_items_downloaded?)
57
+ end
58
+
59
+ # Make sure that a reference to gateway is passed when the get_invoices response is parsed.
60
+ def test_get_contacts_gateway_reference
61
+ result = @gateway.get_invoices
62
+ assert(result.success?)
63
+ assert_not_equal(0, result.invoices.size)
64
+
65
+ result.invoices.each do | invoice |
66
+ assert(invoice.gateway === @gateway)
67
+ end
68
+ end
69
+
70
+ # Test to make sure that we correctly error when an invoice doesn't have an ID.
71
+ # This should usually never be ecountered, but might if a draft invoice is deleted from Xero.
72
+ def test_to_ensure_that_an_invoice_with_invalid_id_errors
73
+ # Make sure there is an invoice to retrieve, even though we will mangle it later.
74
+ invoice = @gateway.create_invoice(dummy_invoice).invoice
75
+
76
+ result = @gateway.get_invoices
77
+ assert_equal(true, result.success?)
78
+
79
+ invoice = result.invoices.first
80
+ assert_equal(false, invoice.line_items_downloaded?)
81
+
82
+ # Mangle invoice_id to invalid one.
83
+ invoice.invoice_id = INVALID_INVOICE_ID
84
+
85
+ # Make sure we fail here.
86
+ line_items = nil
87
+ assert_raise(XeroGateway::InvoiceNotFoundError) { line_items = invoice.line_items }
88
+ assert_nil(line_items)
89
+
90
+ end
91
+
92
+ end
@@ -0,0 +1,50 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class GetManualJournalTest < Test::Unit::TestCase
4
+ include TestHelper
5
+
6
+ def setup
7
+ @gateway = XeroGateway::Gateway.new(CONSUMER_KEY, CONSUMER_SECRET)
8
+
9
+ if STUB_XERO_CALLS
10
+ @gateway.xero_url = "DUMMY_URL"
11
+
12
+ @gateway.stubs(:http_get).with {|client, url, params| url =~ /ManualJournals(\/[0-9a-z\-]+)?$/i }.returns(get_file_as_string("manual_journal.xml"))
13
+ @gateway.stubs(:http_put).with {|client, url, body, params| url =~ /ManualJournals$/ }.returns(get_file_as_string("create_manual_journal.xml"))
14
+ end
15
+ end
16
+
17
+ def test_get_manual_journal
18
+ # Make sure there is a manual journal in Xero to retrieve
19
+ response = @gateway.create_manual_journal(create_test_manual_journal)
20
+ manual_journal = response.manual_journal
21
+
22
+ result = @gateway.get_manual_journal(manual_journal.manual_journal_id)
23
+ assert result.success?
24
+ assert !result.request_params.nil?
25
+ assert !result.response_xml.nil?
26
+ assert_equal result.manual_journal.manual_journal_id, manual_journal.manual_journal_id
27
+ assert_equal result.manual_journal.narration, manual_journal.narration
28
+
29
+ result = @gateway.get_manual_journal(manual_journal.manual_journal_id)
30
+ assert result.success?
31
+ assert !result.request_params.nil?
32
+ assert !result.response_xml.nil?
33
+ assert_equal result.manual_journal.manual_journal_id, manual_journal.manual_journal_id
34
+ end
35
+
36
+ def test_journal_lines_downloaded_set_correctly
37
+ # Make sure there is a manual journal in Xero to retrieve.
38
+ example_manual_journal = @gateway.create_manual_journal(create_test_manual_journal).manual_journal
39
+
40
+ # No line items.
41
+ response = @gateway.get_manual_journal(example_manual_journal.manual_journal_id)
42
+ assert response.success?
43
+
44
+ manual_journal = response.manual_journal
45
+ assert_kind_of(XeroGateway::JournalLine, manual_journal.journal_lines.first)
46
+ assert_kind_of(XeroGateway::ManualJournal, manual_journal)
47
+ assert manual_journal.journal_lines_downloaded?
48
+ end
49
+
50
+ end
@@ -0,0 +1,88 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class GetManualJournalsTest < Test::Unit::TestCase
4
+ include TestHelper
5
+
6
+ INVALID_MANUAL_JOURNAL_ID = "99999999-9999-9999-9999-999999999999" unless defined?(INVALID_MANUAL_JOURNAL_ID)
7
+
8
+ def setup
9
+ @gateway = XeroGateway::Gateway.new(CONSUMER_KEY, CONSUMER_SECRET)
10
+
11
+ if STUB_XERO_CALLS
12
+ @gateway.xero_url = "DUMMY_URL"
13
+
14
+ @gateway.stubs(:http_get).with {|client, url, params| url =~ /ManualJournals(\/[0-9a-z\-]+)?$/i }.returns(get_file_as_string("manual_journals.xml"))
15
+ @gateway.stubs(:http_put).with {|client, url, body, params| url =~ /ManualJournals$/ }.returns(get_file_as_string("create_manual_journal.xml"))
16
+
17
+ # Get a manual journal with an invalid ID.
18
+ @gateway.stubs(:http_get).with {|client, url, params| url =~ Regexp.new("ManualJournals/#{INVALID_MANUAL_JOURNAL_ID}") }.returns(get_file_as_string("manual_journal_not_found_error.xml"))
19
+ end
20
+ end
21
+
22
+ def test_get_manual_journals
23
+ # Make sure there is a manual journal in Xero to retrieve
24
+ manual_journal = @gateway.create_manual_journal(create_test_manual_journal).manual_journal
25
+
26
+ result = @gateway.get_manual_journals
27
+ assert result.success?
28
+ assert !result.request_params.nil?
29
+ assert !result.response_xml.nil?
30
+ assert result.manual_journals.collect {|i| i.narration}.include?(manual_journal.narration)
31
+ assert result.manual_journals.collect {|i| i.manual_journal_id}.include?(manual_journal.manual_journal_id)
32
+ end
33
+
34
+ def test_get_manual_journals_with_modified_since_date
35
+ # Create a test manual journal
36
+ @gateway.create_manual_journal(create_test_manual_journal)
37
+
38
+ # Check that it is returned
39
+ result = @gateway.get_manual_journals(:modified_since => Date.today - 1)
40
+ assert result.success?
41
+ assert !result.request_params.nil?
42
+ assert !result.response_xml.nil?
43
+ assert result.request_params.keys.include?(:ModifiedAfter) # make sure the flag was sent
44
+ end
45
+
46
+ def test_journal_lines_downloaded_set_correctly
47
+ # No line items.
48
+ response = @gateway.get_manual_journals
49
+ assert_equal(true, response.success?)
50
+
51
+ manual_journal = response.manual_journals.first
52
+ assert_kind_of(XeroGateway::ManualJournal, manual_journal)
53
+ assert !manual_journal.journal_lines_downloaded?
54
+ end
55
+
56
+ # Make sure that a reference to gateway is passed when the get_manual_journals response is parsed.
57
+ def test_get_manual_journals_gateway_reference
58
+ result = @gateway.get_manual_journals
59
+ assert(result.success?)
60
+ assert_not_equal(0, result.manual_journals.size)
61
+
62
+ result.manual_journals.each do |manual_journal|
63
+ assert(manual_journal.gateway === @gateway)
64
+ end
65
+ end
66
+
67
+ # Test to make sure that we correctly error when a manual journal doesn't have an ID.
68
+ # This should usually never be ecountered.
69
+ def test_to_ensure_that_a_manual_journal_with_invalid_id_errors
70
+ # Make sure there is a manual journal to retrieve, even though we will mangle it later.
71
+ manual_journal = @gateway.create_manual_journal(create_test_manual_journal).manual_journal
72
+
73
+ result = @gateway.get_manual_journals
74
+ assert_equal(true, result.success?)
75
+
76
+ manual_journal = result.manual_journals.first
77
+ assert !manual_journal.journal_lines_downloaded?
78
+
79
+ # Mangle invoice_id to invalid one.
80
+ manual_journal.manual_journal_id = INVALID_MANUAL_JOURNAL_ID
81
+
82
+ # Make sure we fail here.
83
+ journal_lines = nil
84
+ assert_raise(XeroGateway::ManualJournalNotFoundError) { journal_lines = manual_journal.journal_lines }
85
+ assert_nil(journal_lines)
86
+ end
87
+
88
+ end