xero_gateway 2.1.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +3 -11
  3. data/README.md +212 -0
  4. data/Rakefile +0 -1
  5. data/lib/oauth/oauth_consumer.rb +25 -9
  6. data/lib/xero_gateway.rb +5 -1
  7. data/lib/xero_gateway/address.rb +29 -27
  8. data/lib/xero_gateway/bank_transaction.rb +11 -3
  9. data/lib/xero_gateway/base_record.rb +97 -0
  10. data/lib/xero_gateway/contact_group.rb +87 -0
  11. data/lib/xero_gateway/currency.rb +8 -54
  12. data/lib/xero_gateway/dates.rb +4 -0
  13. data/lib/xero_gateway/exceptions.rb +14 -13
  14. data/lib/xero_gateway/gateway.rb +90 -5
  15. data/lib/xero_gateway/http.rb +16 -8
  16. data/lib/xero_gateway/invoice.rb +9 -3
  17. data/lib/xero_gateway/item.rb +27 -0
  18. data/lib/xero_gateway/line_item_calculations.rb +3 -3
  19. data/lib/xero_gateway/manual_journal.rb +5 -2
  20. data/lib/xero_gateway/organisation.rb +22 -73
  21. data/lib/xero_gateway/payment.rb +22 -9
  22. data/lib/xero_gateway/phone.rb +2 -0
  23. data/lib/xero_gateway/report.rb +95 -0
  24. data/lib/xero_gateway/response.rb +12 -7
  25. data/lib/xero_gateway/tax_rate.rb +13 -61
  26. data/lib/xero_gateway/tracking_category.rb +39 -13
  27. data/lib/xero_gateway/version.rb +3 -0
  28. data/test/integration/get_items_test.rb +25 -0
  29. data/test/integration/get_payments_test.rb +54 -0
  30. data/test/test_helper.rb +51 -16
  31. data/test/unit/address_test.rb +34 -0
  32. data/test/unit/bank_transaction_test.rb +7 -0
  33. data/test/unit/contact_group_test.rb +47 -0
  34. data/test/unit/contact_test.rb +35 -16
  35. data/test/unit/credit_note_test.rb +2 -2
  36. data/test/unit/gateway_test.rb +170 -1
  37. data/test/unit/invoice_test.rb +27 -7
  38. data/test/unit/item_test.rb +51 -0
  39. data/test/unit/organisation_test.rb +1 -0
  40. data/test/unit/payment_test.rb +18 -11
  41. data/test/unit/report_test.rb +78 -0
  42. data/xero_gateway.gemspec +29 -13
  43. metadata +176 -89
  44. data/README.textile +0 -357
  45. data/init.rb +0 -1
@@ -0,0 +1,47 @@
1
+ require File.join(File.dirname(__FILE__), '../test_helper.rb')
2
+
3
+ class ContactGroupTest < Test::Unit::TestCase
4
+ # Tests that a tracking category can be converted into XML that Xero can understand, and then converted back to a tracking category
5
+ def test_build_and_parse_xml
6
+ contact_group = create_test_contact_group
7
+
8
+ # Generate the XML message
9
+ contact_group_as_xml = contact_group.to_xml
10
+
11
+ # Parse the XML message and retrieve the contact group element
12
+ contact_group_element = REXML::XPath.first(REXML::Document.new(contact_group_as_xml), "/ContactGroup")
13
+
14
+ # Build a new contact group from the XML
15
+ result_contact_group = XeroGateway::ContactGroup.from_xml(contact_group_element, nil)
16
+
17
+ # Check the tracking category details
18
+ assert_equal contact_group.contact_group_id, result_contact_group.contact_group_id
19
+ assert_equal contact_group.name, result_contact_group.name
20
+ assert_equal contact_group.contact_ids, result_contact_group.contact_ids
21
+ assert_equal contact_group.status, result_contact_group.status
22
+ end
23
+
24
+ def test_download_and_memoize_contacts_from_partial_load
25
+ stub_contact_list = [stub(), stub()]
26
+ contact_group = create_test_contact_group
27
+ contact_group.gateway = stub()
28
+ contact_group.gateway.expects(:get_contact_group_by_id).with(contact_group.contact_group_id).returns(
29
+ stub(contact_group: stub(contacts: stub_contact_list))
30
+ ).once
31
+
32
+ assert_equal stub_contact_list, contact_group.contacts
33
+ assert_equal stub_contact_list, contact_group.contacts, "Should not reload API call."
34
+ end
35
+
36
+ private
37
+
38
+ def create_test_contact_group
39
+ contact_group = XeroGateway::ContactGroup.new
40
+ contact_group.contact_group_id = "abcd-efgh-ijkl-mnop-qrst-uvwx"
41
+ contact_group.name = "My Group"
42
+ contact_group.contact_ids = %w(abc def hij klm nop qrs)
43
+ contact_group.status = "ACTIVE"
44
+ contact_group
45
+ end
46
+
47
+ end
@@ -4,21 +4,21 @@ class ContactTest < Test::Unit::TestCase
4
4
  def setup
5
5
  @schema = LibXML::XML::Schema.document(LibXML::XML::Document.file(File.join(File.dirname(__FILE__), '../xsd/create_contact.xsd')))
6
6
  end
7
-
7
+
8
8
  # Tests that the XML generated from a contact object validates against the Xero XSD
9
9
  def test_build_xml
10
10
  contact = create_test_contact
11
-
11
+
12
12
  message = contact.to_xml
13
13
 
14
14
  # Check that the document matches the XSD
15
15
  assert LibXML::XML::Parser.string(message).parse.validate_schema(@schema), "The XML document generated did not validate against the XSD"
16
16
  end
17
-
17
+
18
18
  # Tests that a contact can be converted into XML that Xero can understand, and then converted back to a contact
19
19
  def test_build_and_parse_xml
20
20
  contact = create_test_contact
21
-
21
+
22
22
  # Generate the XML message
23
23
  contact_as_xml = contact.to_xml
24
24
 
@@ -27,17 +27,17 @@ class ContactTest < Test::Unit::TestCase
27
27
 
28
28
  # Build a new contact from the XML
29
29
  result_contact = XeroGateway::Contact.from_xml(contact_element)
30
-
30
+
31
31
  # Check the contact details
32
32
  assert_equal contact, result_contact
33
33
  end
34
-
34
+
35
35
  # Test Contact#add_address helper creates a valid XeroGateway::Contact object with the passed in values
36
36
  # and appends it to the Contact#addresses attribute.
37
37
  def test_add_address_helper
38
38
  contact = create_test_contact
39
39
  assert_equal(1, contact.addresses.size)
40
-
40
+
41
41
  new_values = {
42
42
  :address_type => 'POBOX',
43
43
  :line_1 => 'NEW LINE 1',
@@ -50,7 +50,7 @@ class ContactTest < Test::Unit::TestCase
50
50
  :country => 'Australia'
51
51
  }
52
52
  contact.add_address(new_values)
53
-
53
+
54
54
  assert_equal(2, contact.addresses.size)
55
55
  assert_kind_of(XeroGateway::Address, contact.addresses.last)
56
56
  new_values.each { |k,v| assert_equal(v, contact.addresses.last.send("#{k}")) }
@@ -58,10 +58,10 @@ class ContactTest < Test::Unit::TestCase
58
58
 
59
59
  # Test Contact#add_phone helper creates a valid XeroGateway::Phone object with the passed in values
60
60
  # and appends it to the Contact#phones attribute.
61
- def test_add_address_helper
61
+ def test_add_phone_helper
62
62
  contact = create_test_contact
63
63
  assert_equal(1, contact.phones.size)
64
-
64
+
65
65
  new_values = {
66
66
  :phone_type => 'MOBILE',
67
67
  :country_code => '61',
@@ -69,15 +69,34 @@ class ContactTest < Test::Unit::TestCase
69
69
  :number => '123456'
70
70
  }
71
71
  contact.add_phone(new_values)
72
-
72
+
73
73
  assert_equal(2, contact.phones.size)
74
74
  assert_kind_of(XeroGateway::Phone, contact.phones.last)
75
75
  new_values.each { |k,v| assert_equal(v, contact.phones.last.send("#{k}")) }
76
- end
77
-
78
-
76
+ end
77
+
78
+ def test_valid_phone_number
79
+ phone = XeroGateway::Phone.new({
80
+ :phone_type => 'MOBILE',
81
+ :country_code => '61',
82
+ :area_code => '406',
83
+ :number => '0123456789'
84
+ })
85
+ assert(phone.valid?)
86
+ end
87
+
88
+ def test_invalid_phone_number
89
+ phone = XeroGateway::Phone.new({
90
+ :phone_type => 'MOBILE',
91
+ :country_code => '61',
92
+ :area_code => '406',
93
+ :number => '012345678901234567890123456789012345678901234567890'
94
+ })
95
+ assert(!phone.valid?)
96
+ end
97
+
79
98
  private
80
-
99
+
81
100
  def create_test_contact
82
101
  contact = XeroGateway::Contact.new(:contact_id => "55555")
83
102
  contact.contact_number = "aaa111"
@@ -94,4 +113,4 @@ class ContactTest < Test::Unit::TestCase
94
113
 
95
114
  contact
96
115
  end
97
- end
116
+ end
@@ -40,7 +40,7 @@ class CreditNoteTest < Test::Unit::TestCase
40
40
  end
41
41
 
42
42
  # Tests the total_tax calculation and that setting it manually doesn't modify the data.
43
- def test_credit_note_sub_total_calculation
43
+ def test_credit_note_sub_total_calculation2
44
44
  credit_note = create_test_credit_note
45
45
  line_item = credit_note.line_items.first
46
46
 
@@ -61,7 +61,7 @@ class CreditNoteTest < Test::Unit::TestCase
61
61
  end
62
62
 
63
63
  # Tests the total calculation and that setting it manually doesn't modify the data.
64
- def test_credit_note_sub_total_calculation
64
+ def test_credit_note_sub_total_calculation3
65
65
  credit_note = create_test_credit_note
66
66
  line_item = credit_note.line_items.first
67
67
 
@@ -7,8 +7,144 @@ class GatewayTest < Test::Unit::TestCase
7
7
  @gateway = XeroGateway::Gateway.new(CONSUMER_KEY, CONSUMER_SECRET)
8
8
  end
9
9
 
10
- context "with error handling" do
10
+ context "GET methods" do
11
+ should :get_invoices do
12
+ XeroGateway::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("invoices.xml"), :code => "200"))
13
+ result = @gateway.get_invoices
14
+ assert result.response_item.first.is_a? XeroGateway::Invoice
15
+ end
16
+
17
+ should :get_invoice do
18
+ XeroGateway::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("invoice.xml"), :code => "200"))
19
+ result = @gateway.get_invoice('a99a9aaa-9999-99a9-9aa9-aaaaaa9a9999')
20
+ assert result.response_item.is_a? XeroGateway::Invoice
21
+ end
22
+
23
+ should :get_credit_notes do
24
+ XeroGateway::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("credit_notes.xml"), :code => "200"))
25
+ result = @gateway.get_credit_notes
26
+ assert result.response_item.first.is_a? XeroGateway::CreditNote
27
+ end
28
+
29
+ should :get_credit_note do
30
+ XeroGateway::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("credit_notes.xml"), :code => "200"))
31
+ result = @gateway.get_credit_note('a2b4370d-efd2-440d-894e-082f21d0b10a')
32
+ assert result.response_item.first.is_a? XeroGateway::CreditNote
33
+ end
34
+
35
+ should :get_bank_transactions do
36
+ XeroGateway::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("bank_transaction.xml"), :code => "200"))
37
+ result = @gateway.get_bank_transactions
38
+ assert result.response_item.is_a? XeroGateway::BankTransaction
39
+ end
40
+
41
+ should :get_bank_transaction do
42
+ XeroGateway::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("bank_transactions.xml"), :code => "200"))
43
+ result = @gateway.get_bank_transaction('c09661a2-a954-4e34-98df-f8b6d1dc9b19')
44
+ assert result.response_item.is_a? XeroGateway::BankTransaction
45
+ end
46
+
47
+ should :get_manual_journals do
48
+ XeroGateway::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("manual_journals.xml"), :code => "200"))
49
+ result = @gateway.get_manual_journals
50
+ assert result.response_item.is_a? XeroGateway::ManualJournal
51
+ end
52
+
53
+ should :get_payments do
54
+ XeroGateway::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("payments.xml"), :code => "200"))
55
+ result = @gateway.get_payments
56
+ assert result.response_item.first.is_a? XeroGateway::Payment
57
+ end
58
+
59
+ should :get_payment do
60
+ XeroGateway::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("payments.xml"), :code => "200"))
61
+ result = @gateway.get_payment('1234')
62
+ assert result.response_item.first.is_a? XeroGateway::Payment
63
+ end
64
+
65
+
66
+ should :get_contacts do
67
+ XeroGateway::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("contacts.xml"), :code => "200"))
68
+ result = @gateway.get_contacts
69
+ assert result.response_item.first.is_a? XeroGateway::Contact
70
+ end
71
+
72
+ should :get_contact_by_id do
73
+ XeroGateway::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("contact.xml"), :code => "200"))
74
+ result = @gateway.get_contact_by_id('a99a9aaa-9999-99a9-9aa9-aaaaaa9a9999')
75
+ assert result.response_item.is_a? XeroGateway::Contact
76
+ end
77
+
78
+ should :get_contact_by_number do
79
+ XeroGateway::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("contact.xml"), :code => "200"))
80
+ result = @gateway.get_contact_by_number('12345')
81
+ assert result.response_item.is_a? XeroGateway::Contact
82
+ end
83
+
84
+ should :get_contact_groups do
85
+ XeroGateway::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("contact_groups.xml"), :code => "200"))
86
+ result = @gateway.get_contact_groups
87
+ assert result.response_item.first.is_a? XeroGateway::ContactGroup
88
+ end
89
+
90
+ should :get_contact_group_by_id do
91
+ XeroGateway::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("contact_group.xml"), :code => "200"))
92
+ result = @gateway.get_contact_group_by_id('a99a9aaa-9999-99a9-9aa9-aaaaaa9a9999')
93
+ assert result.response_item.is_a? XeroGateway::ContactGroup
94
+ end
95
+
96
+ context :get_report do
97
+ should "get a BankStatements report" do
98
+ XeroGateway::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("reports/bank_statement.xml"), :code => "200"))
99
+ result = @gateway.get_report("BankStatement", bank_account_id: "c09661a2-a954-4e34-98df-f8b6d1dc9b19")
100
+ assert result.response_item.is_a? XeroGateway::Report
101
+ end
102
+
103
+ should "get a AgedPayablesByContact report" do
104
+ XeroGateway::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("reports/aged_payables_by_contact.xml"), :code => "200"))
105
+ result = @gateway.get_report("AgedPayablesByContact", contactID: "c09661a2-a954-4e34-98df-f8b6d1dc9b19")
106
+ assert result.response_item.is_a? XeroGateway::Report
107
+ end
11
108
 
109
+ should "get a AgedReceivablesByContact report" do
110
+ XeroGateway::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("reports/aged_receivables_by_contact.xml"), :code => "200"))
111
+ result = @gateway.get_report("AgedReceivablesByContact", contactID: "c09661a2-a954-4e34-98df-f8b6d1dc9b19")
112
+ assert result.response_item.is_a? XeroGateway::Report
113
+ end
114
+
115
+ should "get a BalanceSheet report" do
116
+ XeroGateway::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("reports/balance_sheet.xml"), :code => "200"))
117
+ result = @gateway.get_report("BalanceSheet")
118
+ assert result.response_item.is_a? XeroGateway::Report
119
+ end
120
+
121
+ should "get a BankSummary report" do
122
+ XeroGateway::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("reports/bank_summary.xml"), :code => "200"))
123
+ result = @gateway.get_report("BankSummary")
124
+ assert result.response_item.is_a? XeroGateway::Report
125
+ end
126
+
127
+ should "get a ExecutiveSummary report" do
128
+ XeroGateway::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("reports/executive_summary.xml"), :code => "200"))
129
+ result = @gateway.get_report("ExecutiveSummary")
130
+ assert result.response_item.is_a? XeroGateway::Report
131
+ end
132
+
133
+ should "get a ProfitAndLoss report" do
134
+ XeroGateway::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("reports/profit_and_loss.xml"), :code => "200"))
135
+ result = @gateway.get_report("ProfitAndLoss")
136
+ assert result.response_item.is_a? XeroGateway::Report
137
+ end
138
+
139
+ should "get a TrialBalance report" do
140
+ XeroGateway::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("reports/trial_balance.xml"), :code => "200"))
141
+ result = @gateway.get_report("TrialBalance")
142
+ assert result.response_item.is_a? XeroGateway::Report
143
+ end
144
+ end
145
+ end
146
+
147
+ context "with error handling" do
12
148
  should "handle token expired" do
13
149
  XeroGateway::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("token_expired"), :code => "401"))
14
150
 
@@ -49,6 +185,16 @@ class GatewayTest < Test::Unit::TestCase
49
185
  end
50
186
  end
51
187
 
188
+ should "handle errors without advice" do
189
+ XeroGateway::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("error_without_advice"), :code => "401"))
190
+
191
+ begin
192
+ @gateway.get_accounts
193
+ rescue XeroGateway::OAuth::UnknownError => e
194
+ assert_equal "some_error: No description found: oauth_problem=some_error&oauth_problem_advice=\n", e.message
195
+ end
196
+ end
197
+
52
198
  should "handle ApiExceptions" do
53
199
  XeroGateway::OAuth.any_instance.stubs(:put).returns(stub(:plain_body => get_file_as_string("api_exception.xml"), :code => "400"))
54
200
 
@@ -81,6 +227,22 @@ class GatewayTest < Test::Unit::TestCase
81
227
  end
82
228
  end
83
229
 
230
+ should "handle manual journals not found" do
231
+ XeroGateway::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("api_exception.xml"), :code => "404"))
232
+
233
+ assert_raises XeroGateway::ManualJournalNotFoundError do
234
+ @gateway.get_manual_journal('unknown-manual-journal-id')
235
+ end
236
+ end
237
+
238
+ should "handle payments not found" do
239
+ XeroGateway::OAuth.any_instance.stubs(:get).returns(stub(:plain_body => get_file_as_string("api_exception.xml"), :code => "404"))
240
+
241
+ assert_raises XeroGateway::PaymentNotFoundError do
242
+ @gateway.get_payments
243
+ end
244
+ end
245
+
84
246
  should "handle random root elements" do
85
247
  XeroGateway::OAuth.any_instance.stubs(:put).returns(stub(:plain_body => "<RandomRootElement></RandomRootElement>", :code => "200"))
86
248
 
@@ -89,6 +251,13 @@ class GatewayTest < Test::Unit::TestCase
89
251
  end
90
252
  end
91
253
 
254
+ should "handle no root element" do
255
+ XeroGateway::OAuth.any_instance.stubs(:put).returns(stub(:plain_body => get_file_as_string("no_certificates_registered"), :code => 400))
256
+
257
+ assert_raises RuntimeError do
258
+ response = @gateway.create_invoice(XeroGateway::Invoice.new)
259
+ end
260
+ end
92
261
  end
93
262
 
94
263
  def test_unknown_error_handling
@@ -2,6 +2,17 @@ require File.join(File.dirname(__FILE__), '../test_helper.rb')
2
2
 
3
3
  class InvoiceTest < Test::Unit::TestCase
4
4
 
5
+ context "with line item totals" do
6
+
7
+ should "allow setting and reading these as instance variables without downloading line items" do
8
+ invoice = create_test_invoice(:line_items_downloaded => false, :total => 6969_00)
9
+
10
+ assert !invoice.line_items_downloaded?
11
+ XeroGateway::Invoice.any_instance.expects(:download_line_items).never
12
+ assert_equal 6969_00, invoice.total
13
+ end
14
+ end
15
+
5
16
  context "building and parsing XML" do
6
17
  should "work vice versa" do
7
18
  invoice = create_test_invoice
@@ -30,7 +41,7 @@ class InvoiceTest < Test::Unit::TestCase
30
41
 
31
42
  # Tests the sub_total calculation and that setting it manually doesn't modify the data.
32
43
  def test_invoice_sub_total_calculation
33
- invoice = create_test_invoice
44
+ invoice = create_test_invoice(:line_items_downloaded => true)
34
45
  line_item = invoice.line_items.first
35
46
 
36
47
  # Make sure that everything adds up to begin with.
@@ -50,8 +61,8 @@ class InvoiceTest < Test::Unit::TestCase
50
61
  end
51
62
 
52
63
  # Tests the total_tax calculation and that setting it manually doesn't modify the data.
53
- def test_invoice_sub_total_calculation
54
- invoice = create_test_invoice
64
+ def test_invoice_sub_total_calculation2
65
+ invoice = create_test_invoice(:line_items_downloaded => true)
55
66
  line_item = invoice.line_items.first
56
67
 
57
68
  # Make sure that everything adds up to begin with.
@@ -71,8 +82,9 @@ class InvoiceTest < Test::Unit::TestCase
71
82
  end
72
83
 
73
84
  # Tests the total calculation and that setting it manually doesn't modify the data.
74
- def test_invoice_sub_total_calculation
75
- invoice = create_test_invoice
85
+ def test_invoice_sub_total_calculation3
86
+ invoice = create_test_invoice(:line_items_downloaded => true)
87
+ assert invoice.line_items_downloaded?
76
88
  line_item = invoice.line_items.first
77
89
 
78
90
  # Make sure that everything adds up to begin with.
@@ -81,7 +93,7 @@ class InvoiceTest < Test::Unit::TestCase
81
93
 
82
94
  # Change the total and check that it doesn't modify anything.
83
95
  invoice.total = expected_total * 10
84
- assert_equal(expected_total, invoice.total)
96
+ assert_equal(expected_total.to_f, invoice.total.to_f)
85
97
 
86
98
  # Change the quantity of the first line item and make sure that
87
99
  # everything still continues to add up.
@@ -146,6 +158,7 @@ class InvoiceTest < Test::Unit::TestCase
146
158
  assert_equal('ACCREC', invoice.invoice_type)
147
159
  assert_kind_of(Date, invoice.date)
148
160
  assert_kind_of(Date, invoice.due_date)
161
+ assert_kind_of(Time, invoice.updated_date_utc)
149
162
  assert_equal('12345', invoice.invoice_number)
150
163
  assert_equal('MY REFERENCE FOR THIS INVOICE', invoice.reference)
151
164
  assert_equal("Exclusive", invoice.line_amount_types)
@@ -245,6 +258,12 @@ class InvoiceTest < Test::Unit::TestCase
245
258
  assert_equal 'a94a78db-5cc6-4e26-a52b-045237e56e6e', invoice.branding_theme_id
246
259
  end
247
260
 
261
+ def test_updated_date_utc
262
+ time = Time.now.utc
263
+ invoice = create_test_invoice(:updated_date_utc => time)
264
+ assert_equal time, invoice.updated_date_utc
265
+ end
266
+
248
267
  private
249
268
 
250
269
  def create_test_invoice(invoice_params = {}, contact_params = {}, line_item_params = [])
@@ -255,7 +274,8 @@ class InvoiceTest < Test::Unit::TestCase
255
274
  :due_date => Date.today + 10, # 10 days in the future
256
275
  :invoice_number => '12345',
257
276
  :reference => "MY REFERENCE FOR THIS INVOICE",
258
- :line_amount_types => "Exclusive"
277
+ :line_amount_types => "Exclusive",
278
+ :updated_date_utc => Time.now.utc
259
279
  }.merge(invoice_params)
260
280
  end
261
281
  invoice = XeroGateway::Invoice.new(invoice_params || {})