xeroizer 2.17.1 → 3.0.0
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.
- checksums.yaml +5 -5
- data/README.md +246 -213
- data/lib/xeroizer/connection.rb +49 -0
- data/lib/xeroizer/exceptions.rb +4 -0
- data/lib/xeroizer/generic_application.rb +13 -5
- data/lib/xeroizer/http.rb +7 -80
- data/lib/xeroizer/http_response.rb +154 -0
- data/lib/xeroizer/models/bank_account.rb +1 -0
- data/lib/xeroizer/models/bank_transaction.rb +1 -0
- data/lib/xeroizer/models/batch_payment.rb +27 -0
- data/lib/xeroizer/models/branding_theme.rb +49 -9
- data/lib/xeroizer/models/contact.rb +12 -6
- data/lib/xeroizer/models/contact_group.rb +45 -0
- data/lib/xeroizer/models/credit_note.rb +24 -22
- data/lib/xeroizer/models/currency.rb +14 -2
- data/lib/xeroizer/models/from_bank_account.rb +1 -0
- data/lib/xeroizer/models/history_record.rb +72 -0
- data/lib/xeroizer/models/invoice.rb +17 -3
- data/lib/xeroizer/models/item.rb +2 -1
- data/lib/xeroizer/models/item_purchase_details.rb +1 -1
- data/lib/xeroizer/models/line_item.rb +17 -5
- data/lib/xeroizer/models/manual_journal.rb +2 -1
- data/lib/xeroizer/models/online_invoice.rb +37 -0
- data/lib/xeroizer/models/option.rb +1 -1
- data/lib/xeroizer/models/organisation.rb +2 -0
- data/lib/xeroizer/models/payment_service.rb +22 -0
- data/lib/xeroizer/models/payroll/address.rb +53 -0
- data/lib/xeroizer/models/payroll/bank_account.rb +18 -6
- data/lib/xeroizer/models/payroll/benefit_line.rb +26 -0
- data/lib/xeroizer/models/payroll/benefit_type.rb +45 -0
- data/lib/xeroizer/models/payroll/deduction_line.rb +32 -0
- data/lib/xeroizer/models/payroll/deduction_type.rb +49 -0
- data/lib/xeroizer/models/payroll/earnings_line.rb +39 -0
- data/lib/xeroizer/models/payroll/earnings_type.rb +53 -0
- data/lib/xeroizer/models/payroll/employee.rb +30 -8
- data/lib/xeroizer/models/payroll/leave_application.rb +27 -0
- data/lib/xeroizer/models/payroll/leave_line.rb +30 -0
- data/lib/xeroizer/models/payroll/leave_period.rb +15 -0
- data/lib/xeroizer/models/payroll/pay_items.rb +22 -0
- data/lib/xeroizer/models/payroll/pay_run.rb +33 -0
- data/lib/xeroizer/models/payroll/pay_schedule.rb +40 -0
- data/lib/xeroizer/models/payroll/pay_template.rb +24 -0
- data/lib/xeroizer/models/payroll/payment_method.rb +24 -0
- data/lib/xeroizer/models/payroll/paystub.rb +44 -0
- data/lib/xeroizer/models/payroll/reimbursement_line.rb +21 -0
- data/lib/xeroizer/models/payroll/reimbursement_type.rb +22 -0
- data/lib/xeroizer/models/payroll/salary_and_wage.rb +29 -0
- data/lib/xeroizer/models/payroll/super_line.rb +40 -0
- data/lib/xeroizer/models/payroll/tax_declaration.rb +50 -0
- data/lib/xeroizer/models/payroll/time_off_line.rb +20 -0
- data/lib/xeroizer/models/payroll/time_off_type.rb +32 -0
- data/lib/xeroizer/models/payroll/work_location.rb +25 -0
- data/lib/xeroizer/models/prepayment.rb +1 -0
- data/lib/xeroizer/models/purchase_order.rb +6 -6
- data/lib/xeroizer/models/quote.rb +76 -0
- data/lib/xeroizer/models/schedule.rb +1 -0
- data/lib/xeroizer/models/tax_component.rb +1 -0
- data/lib/xeroizer/models/to_bank_account.rb +1 -0
- data/lib/xeroizer/oauth.rb +12 -1
- data/lib/xeroizer/oauth2.rb +82 -0
- data/lib/xeroizer/oauth2_application.rb +49 -0
- data/lib/xeroizer/payroll_application.rb +8 -3
- data/lib/xeroizer/record/base.rb +11 -2
- data/lib/xeroizer/record/base_model.rb +1 -1
- data/lib/xeroizer/record/base_model_http_proxy.rb +37 -17
- data/lib/xeroizer/record/model_definition_helper.rb +1 -1
- data/lib/xeroizer/record/payroll_base.rb +4 -0
- data/lib/xeroizer/record/record_association_helper.rb +4 -4
- data/lib/xeroizer/record/validators/associated_validator.rb +1 -0
- data/lib/xeroizer/record/xml_helper.rb +18 -18
- data/lib/xeroizer/report/aged_receivables_by_contact.rb +1 -1
- data/lib/xeroizer/report/cell_xml_helper.rb +13 -13
- data/lib/xeroizer/response.rb +22 -17
- data/lib/xeroizer/version.rb +1 -1
- data/lib/xeroizer.rb +34 -4
- data/test/acceptance/about_creating_bank_transactions_test.rb +89 -81
- data/test/acceptance/about_creating_prepayment_test.rb +25 -30
- data/test/acceptance/about_fetching_bank_transactions_test.rb +12 -12
- data/test/acceptance/about_online_invoice_test.rb +25 -0
- data/test/acceptance/acceptance_test.rb +28 -26
- data/test/acceptance/bank_transfer_test.rb +12 -17
- data/test/acceptance/bulk_operations_test.rb +18 -16
- data/test/acceptance/connections_test.rb +11 -0
- data/test/stub_responses/bad_request.json +6 -0
- data/test/stub_responses/connections.json +16 -0
- data/test/stub_responses/expired_oauth2_token.json +6 -0
- data/test/stub_responses/generic_response_error.json +6 -0
- data/test/stub_responses/invalid_oauth2_request_token.json +6 -0
- data/test/stub_responses/invalid_tenant_header.json +6 -0
- data/test/stub_responses/object_not_found.json +6 -0
- data/test/stub_responses/organisations.xml +10 -0
- data/test/stub_responses/payment_service.xml +15 -0
- data/test/test_helper.rb +17 -12
- data/test/unit/generic_application_test.rb +21 -10
- data/test/unit/http_test.rb +282 -10
- data/test/unit/models/address_test.rb +2 -2
- data/test/unit/models/bank_transaction_model_parsing_test.rb +2 -2
- data/test/unit/models/bank_transaction_test.rb +1 -1
- data/test/unit/models/bank_transaction_validation_test.rb +1 -1
- data/test/unit/models/contact_test.rb +20 -11
- data/test/unit/models/credit_note_test.rb +8 -8
- data/test/unit/models/employee_test.rb +4 -4
- data/test/unit/models/invoice_test.rb +12 -12
- data/test/unit/models/journal_line_test.rb +6 -6
- data/test/unit/models/journal_test.rb +4 -4
- data/test/unit/models/line_item_sum_test.rb +1 -1
- data/test/unit/models/line_item_test.rb +29 -37
- data/test/unit/models/manual_journal_test.rb +3 -3
- data/test/unit/models/organisation_test.rb +16 -2
- data/test/unit/models/payment_service_test.rb +29 -0
- data/test/unit/models/phone_test.rb +7 -7
- data/test/unit/models/prepayment_test.rb +4 -4
- data/test/unit/models/repeating_invoice_test.rb +3 -3
- data/test/unit/models/tax_rate_test.rb +2 -2
- data/test/unit/oauth2_test.rb +171 -0
- data/test/unit/oauth_config_test.rb +1 -1
- data/test/unit/record/base_model_test.rb +13 -13
- data/test/unit/record/base_test.rb +73 -4
- data/test/unit/record/block_validator_test.rb +1 -1
- data/test/unit/record/connection_test.rb +60 -0
- data/test/unit/record/model_definition_test.rb +36 -36
- data/test/unit/record/parse_params_test.rb +59 -0
- data/test/unit/record/parse_where_hash_test.rb +13 -13
- data/test/unit/record/record_association_test.rb +14 -14
- data/test/unit/record/validators_test.rb +43 -43
- data/test/unit/record_definition_test.rb +7 -7
- data/test/unit/report_definition_test.rb +7 -7
- data/test/unit/report_test.rb +20 -20
- data/test/unit_test_helper.rb +16 -0
- metadata +117 -27
- data/lib/xeroizer/models/payroll/home_address.rb +0 -24
- data/lib/xeroizer/partner_application.rb +0 -51
- data/lib/xeroizer/private_application.rb +0 -25
- data/lib/xeroizer/public_application.rb +0 -21
- data/test/unit/oauth_test.rb +0 -118
- data/test/unit/private_application_test.rb +0 -20
@@ -1,13 +1,13 @@
|
|
1
|
-
require '
|
1
|
+
require 'unit_test_helper'
|
2
2
|
|
3
3
|
class ValidatorsTest < Test::Unit::TestCase
|
4
4
|
include TestHelper
|
5
|
-
|
5
|
+
|
6
6
|
class Xeroizer::Record::TestModel < Xeroizer::Record::BaseModel
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
class Xeroizer::Record::Test < Xeroizer::Record::Base
|
10
|
-
|
10
|
+
|
11
11
|
string :name
|
12
12
|
string :name_conditional_if
|
13
13
|
string :name_conditional_unless
|
@@ -16,7 +16,7 @@ class ValidatorsTest < Test::Unit::TestCase
|
|
16
16
|
string :type
|
17
17
|
string :type_blank
|
18
18
|
integer :value
|
19
|
-
|
19
|
+
|
20
20
|
belongs_to :contact
|
21
21
|
has_many :addresses
|
22
22
|
|
@@ -29,81 +29,81 @@ class ValidatorsTest < Test::Unit::TestCase
|
|
29
29
|
validates_inclusion_of :type_blank, :in => %w(phone fax mobile), :message => "not_included_blank", :allow_blanks => true
|
30
30
|
validates_associated :contact, :message => "association_invalid"
|
31
31
|
validates_associated :addresses, :message => "association_invalid_blank", :allow_blanks => true
|
32
|
-
|
32
|
+
|
33
33
|
def value_equals_ten?
|
34
34
|
value == 10
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
def value_equals_twenty?
|
38
38
|
value == 20
|
39
39
|
end
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
def setup
|
43
|
-
@client = Xeroizer::
|
43
|
+
@client = Xeroizer::OAuth2Application.new(CLIENT_ID, CLIENT_SECRET)
|
44
44
|
@record = Xeroizer::Record::TestModel.new(@client, 'Test').build
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
context "associated validator" do
|
48
|
-
|
48
|
+
|
49
49
|
should "exist and be valid" do
|
50
50
|
# Nil contact
|
51
51
|
assert_equal(false, @record.valid?)
|
52
52
|
error = @record.errors_for(:contact).first
|
53
53
|
assert_not_nil(error)
|
54
54
|
assert_equal('association_invalid', error)
|
55
|
-
|
55
|
+
|
56
56
|
# Valid contact
|
57
57
|
@record.build_contact({:name => 'VALID NAME'})
|
58
58
|
@record.valid?
|
59
59
|
error = @record.errors_for(:contact).first
|
60
60
|
assert_nil(error)
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
should "exist and be valid unless allowed to be blank" do
|
64
64
|
# Nil address
|
65
65
|
assert_equal(false, @record.valid?)
|
66
66
|
error = @record.errors_for(:addresses).first
|
67
67
|
assert_nil(error)
|
68
|
-
|
68
|
+
|
69
69
|
# Valid address
|
70
70
|
@record.add_address(:type => 'STREET')
|
71
71
|
@record.valid?
|
72
72
|
error = @record.errors_for(:addresses).first
|
73
73
|
assert_nil(error)
|
74
|
-
|
74
|
+
|
75
75
|
# Invalid address
|
76
76
|
@record.addresses[0].type = "INVALID TYPE"
|
77
77
|
@record.valid?
|
78
78
|
error = @record.errors_for(:addresses).first
|
79
79
|
assert_equal('association_invalid_blank', error)
|
80
|
-
|
80
|
+
|
81
81
|
# One invalid address
|
82
82
|
@record.add_address(:type => 'STREET')
|
83
83
|
assert_equal(2, @record.addresses.size)
|
84
84
|
@record.valid?
|
85
85
|
error = @record.errors_for(:addresses).first
|
86
|
-
assert_equal('association_invalid_blank', error)
|
86
|
+
assert_equal('association_invalid_blank', error)
|
87
87
|
end
|
88
|
-
|
88
|
+
|
89
89
|
end
|
90
|
-
|
90
|
+
|
91
91
|
context "inclusion validator" do
|
92
|
-
|
92
|
+
|
93
93
|
should "be included in list" do
|
94
94
|
# Nil type
|
95
95
|
assert_equal(false, @record.valid?)
|
96
96
|
error = @record.errors_for(:type).first
|
97
97
|
assert_not_nil(error)
|
98
98
|
assert_equal('not_included', error)
|
99
|
-
|
99
|
+
|
100
100
|
# Invalid type
|
101
101
|
@record.type = 'phone not valid'
|
102
102
|
@record.valid?
|
103
103
|
error = @record.errors_for(:type).first
|
104
104
|
assert_not_nil(error)
|
105
105
|
assert_equal('not_included', error)
|
106
|
-
|
106
|
+
|
107
107
|
# Valid type
|
108
108
|
%w(phone fax mobile).each do | valid_type |
|
109
109
|
@record.type = valid_type
|
@@ -112,20 +112,20 @@ class ValidatorsTest < Test::Unit::TestCase
|
|
112
112
|
assert_nil(error)
|
113
113
|
end
|
114
114
|
end
|
115
|
-
|
115
|
+
|
116
116
|
should "be included in list unless allowed to be blank" do
|
117
117
|
# Nil type_blank
|
118
118
|
assert_equal(false, @record.valid?)
|
119
119
|
error = @record.errors_for(:type_blank).first
|
120
120
|
assert_nil(error)
|
121
|
-
|
121
|
+
|
122
122
|
# Invalid type_blank
|
123
123
|
@record.type_blank = 'phone not valid'
|
124
124
|
@record.valid?
|
125
125
|
error = @record.errors_for(:type_blank).first
|
126
126
|
assert_not_nil(error)
|
127
127
|
assert_equal('not_included_blank', error)
|
128
|
-
|
128
|
+
|
129
129
|
# Valid type_blank
|
130
130
|
%w(phone fax mobile).each do | valid_type |
|
131
131
|
@record.type_blank = valid_type
|
@@ -134,95 +134,95 @@ class ValidatorsTest < Test::Unit::TestCase
|
|
134
134
|
assert_nil(error)
|
135
135
|
end
|
136
136
|
end
|
137
|
-
|
137
|
+
|
138
138
|
end
|
139
|
-
|
139
|
+
|
140
140
|
context "presence validator" do
|
141
|
-
|
141
|
+
|
142
142
|
should "have name" do
|
143
143
|
assert_equal(false, @record.valid?)
|
144
144
|
error = @record.errors_for(:name).first
|
145
145
|
assert_not_nil(error)
|
146
146
|
assert_equal('blank', error)
|
147
|
-
|
147
|
+
|
148
148
|
@record.name = "NOT BLANK"
|
149
149
|
@record.valid?
|
150
150
|
error = @record.errors_for(:name).first
|
151
151
|
assert_nil(error)
|
152
152
|
end
|
153
|
-
|
153
|
+
|
154
154
|
should "have name if value is 10" do
|
155
155
|
@record.value = 10
|
156
156
|
assert_equal(false, @record.valid?)
|
157
157
|
error = @record.errors_for(:name_conditional_if).first
|
158
158
|
assert_equal('blank_if_10', error)
|
159
|
-
|
159
|
+
|
160
160
|
@record.name_conditional_if = "NOT BLANK"
|
161
161
|
@record.valid?
|
162
162
|
error = @record.errors_for(:name_conditional_if).first
|
163
163
|
assert_nil(error)
|
164
|
-
|
164
|
+
|
165
165
|
@record.name_conditional_if = nil
|
166
166
|
@record.value = 50
|
167
167
|
@record.valid?
|
168
168
|
error = @record.errors_for(:name_conditional_if).first
|
169
169
|
assert_nil(error)
|
170
170
|
end
|
171
|
-
|
171
|
+
|
172
172
|
should "have name if value_equals_ten?" do
|
173
173
|
@record.value = 10
|
174
174
|
assert_equal(false, @record.valid?)
|
175
175
|
error = @record.errors_for(:name_conditional_method_if).first
|
176
176
|
assert_equal('blank_if_10', error)
|
177
|
-
|
177
|
+
|
178
178
|
@record.name_conditional_method_if = "NOT BLANK"
|
179
179
|
@record.valid?
|
180
180
|
error = @record.errors_for(:name_conditional_method_if).first
|
181
181
|
assert_nil(error)
|
182
|
-
|
182
|
+
|
183
183
|
@record.name_conditional_method_if = nil
|
184
184
|
@record.value = 50
|
185
185
|
@record.valid?
|
186
186
|
error = @record.errors_for(:name_conditional_method_if).first
|
187
187
|
assert_nil(error)
|
188
188
|
end
|
189
|
-
|
189
|
+
|
190
190
|
should "have name unless value is 20" do
|
191
191
|
@record.value = 50
|
192
192
|
assert_equal(false, @record.valid?)
|
193
193
|
error = @record.errors_for(:name_conditional_unless).first
|
194
194
|
assert_equal('blank_unless_20', error)
|
195
|
-
|
195
|
+
|
196
196
|
@record.name_conditional_unless = "NOT BLANK"
|
197
197
|
@record.valid?
|
198
198
|
error = @record.errors_for(:name_conditional_unless).first
|
199
199
|
assert_nil(error)
|
200
|
-
|
200
|
+
|
201
201
|
@record.name_conditional_unless = nil
|
202
202
|
@record.value = 20
|
203
203
|
@record.valid?
|
204
204
|
error = @record.errors_for(:name_conditional_unless).first
|
205
205
|
assert_nil(error)
|
206
206
|
end
|
207
|
-
|
207
|
+
|
208
208
|
should "have name unless value_equals_twenty?" do
|
209
209
|
@record.value = 50
|
210
210
|
assert_equal(false, @record.valid?)
|
211
211
|
error = @record.errors_for(:name_conditional_method_unless).first
|
212
212
|
assert_equal('blank_unless_20', error)
|
213
|
-
|
213
|
+
|
214
214
|
@record.name_conditional_method_unless = "NOT BLANK"
|
215
215
|
@record.valid?
|
216
216
|
error = @record.errors_for(:name_conditional_method_unless).first
|
217
217
|
assert_nil(error)
|
218
|
-
|
218
|
+
|
219
219
|
@record.name_conditional_method_unless = nil
|
220
220
|
@record.value = 20
|
221
221
|
@record.valid?
|
222
222
|
error = @record.errors_for(:name_conditional_method_unless).first
|
223
223
|
assert_nil(error)
|
224
224
|
end
|
225
|
-
|
225
|
+
|
226
226
|
end
|
227
|
-
|
227
|
+
|
228
228
|
end
|
@@ -1,16 +1,16 @@
|
|
1
|
-
require '
|
1
|
+
require 'unit_test_helper'
|
2
2
|
|
3
3
|
class RecordDefinitionTest < Test::Unit::TestCase
|
4
4
|
include TestHelper
|
5
|
-
|
5
|
+
|
6
6
|
def setup
|
7
|
-
@client = Xeroizer::
|
7
|
+
@client = Xeroizer::OAuth2Application.new(CLIENT_ID, CLIENT_SECRET)
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
context "record definitions" do
|
11
|
-
|
11
|
+
|
12
12
|
should "be defined correctly" do
|
13
|
-
[
|
13
|
+
[
|
14
14
|
:Account, :BrandingTheme, :Contact, :CreditNote, :Currency, :Invoice,
|
15
15
|
:Item, :Journal, :ManualJournal, :Organisation, :Payment, :TaxRate,
|
16
16
|
:TrackingCategory, :User
|
@@ -21,7 +21,7 @@ class RecordDefinitionTest < Test::Unit::TestCase
|
|
21
21
|
assert_equal(record_type.to_s, record_factory.model_name)
|
22
22
|
end
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
end
|
26
26
|
|
27
27
|
end
|
@@ -1,16 +1,16 @@
|
|
1
|
-
require '
|
1
|
+
require 'unit_test_helper'
|
2
2
|
|
3
3
|
class ReportDefinitionTest < Test::Unit::TestCase
|
4
4
|
include TestHelper
|
5
|
-
|
5
|
+
|
6
6
|
def setup
|
7
|
-
@client = Xeroizer::
|
7
|
+
@client = Xeroizer::OAuth2Application.new(CLIENT_ID, CLIENT_SECRET)
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
context "report definitions" do
|
11
|
-
|
11
|
+
|
12
12
|
should "be defined correctly" do
|
13
|
-
[
|
13
|
+
[
|
14
14
|
:AgedPayablesByContact, :AgedReceivablesByContact, :BalanceSheet, :BankStatement, :BankSummary,
|
15
15
|
:BudgetSummary, :ExecutiveSummary, :ProfitAndLoss, :TrialBalance
|
16
16
|
].each do | report_type |
|
@@ -20,7 +20,7 @@ class ReportDefinitionTest < Test::Unit::TestCase
|
|
20
20
|
assert_equal(report_type.to_s, report_factory.report_type)
|
21
21
|
end
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
end
|
25
25
|
|
26
26
|
end
|
data/test/unit/report_test.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
require '
|
1
|
+
require 'unit_test_helper'
|
2
2
|
|
3
3
|
class MockNonReportClassDefinition; end
|
4
4
|
|
5
5
|
class FactoryTest < Test::Unit::TestCase
|
6
6
|
include TestHelper
|
7
|
-
|
7
|
+
|
8
8
|
def setup
|
9
|
-
@client = Xeroizer::
|
9
|
+
@client = Xeroizer::OAuth2Application.new(CLIENT_ID, CLIENT_SECRET)
|
10
10
|
mock_report_api("TrialBalance")
|
11
11
|
@report = @client.TrialBalance.get
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
context "report factory" do
|
15
|
-
|
15
|
+
|
16
16
|
should "have correct API-part of URL based on its type" do
|
17
|
-
[
|
17
|
+
[
|
18
18
|
:AgedPayablesByContact, :AgedReceivablesByContact, :BalanceSheet, :BankStatement, :BankSummary,
|
19
19
|
:BudgetSummary, :ExecutiveSummary, :ProfitAndLoss, :TrialBalance
|
20
20
|
].each do | report_type |
|
@@ -22,11 +22,11 @@ class FactoryTest < Test::Unit::TestCase
|
|
22
22
|
assert_equal("Reports/#{report_type}", report_factory.api_controller_name)
|
23
23
|
end
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
should "build report model from XML" do
|
27
27
|
assert_kind_of(Xeroizer::Report::Base, @report)
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
should "have all attributes in report summary" do
|
31
31
|
assert_equal("TrialBalance", @report.id)
|
32
32
|
assert_equal("TrialBalance", @report.type)
|
@@ -35,7 +35,7 @@ class FactoryTest < Test::Unit::TestCase
|
|
35
35
|
assert_equal(Date.parse('2011-03-23'), @report.date)
|
36
36
|
assert_equal(Time.parse('2011-03-23T00:29:12.6021453Z'), @report.updated_at)
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
should "have valid rows" do
|
40
40
|
assert_not_equal(0, @report.rows.size)
|
41
41
|
@report.rows.each do | row |
|
@@ -43,7 +43,7 @@ class FactoryTest < Test::Unit::TestCase
|
|
43
43
|
assert(%w(Header Row SummaryRow Section).include?(row.type), "'#{row.type}' is not a valid row type.")
|
44
44
|
end
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
should "have cells and no rows if not Section" do
|
48
48
|
@report.rows.each do | row |
|
49
49
|
if row.type != 'Section'
|
@@ -52,7 +52,7 @@ class FactoryTest < Test::Unit::TestCase
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
should "have rows and no cells if Section" do
|
57
57
|
@report.rows.each do | row |
|
58
58
|
if row.type == 'Section'
|
@@ -61,7 +61,7 @@ class FactoryTest < Test::Unit::TestCase
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
65
|
should "convert cells to BigDecimal where possible" do
|
66
66
|
def assess_row(row)
|
67
67
|
return 0 unless row.row? || row.summary?
|
@@ -82,7 +82,7 @@ class FactoryTest < Test::Unit::TestCase
|
|
82
82
|
end
|
83
83
|
assert_not_equal(0, counter, "at least one converted number in the report should be greater than 0")
|
84
84
|
end
|
85
|
-
|
85
|
+
|
86
86
|
should "be at least one Section row with a title" do
|
87
87
|
counter = 0
|
88
88
|
@report.rows.each do | row |
|
@@ -101,24 +101,24 @@ class FactoryTest < Test::Unit::TestCase
|
|
101
101
|
end
|
102
102
|
end
|
103
103
|
end
|
104
|
-
|
104
|
+
|
105
105
|
should "have valid header row" do
|
106
106
|
assert_kind_of(Xeroizer::Report::HeaderRow, @report.header)
|
107
107
|
assert_equal(['Account', 'Debit', 'Credit', 'YTD Debit', 'YTD Credit'], @report.header.cells.map { | c | c.value })
|
108
108
|
end
|
109
|
-
|
109
|
+
|
110
110
|
should "have sections" do
|
111
111
|
assert_not_equal(0, @report.sections)
|
112
112
|
@report.sections.each do | section |
|
113
113
|
assert_kind_of(Xeroizer::Report::SectionRow, section)
|
114
114
|
end
|
115
115
|
end
|
116
|
-
|
116
|
+
|
117
117
|
should "have summary" do
|
118
118
|
assert_kind_of(Xeroizer::Report::SummaryRow, @report.summary)
|
119
119
|
assert_equal(['Total', '33244.04', '33244.04', '80938.93', '80938.93'], @report.summary.cells.map { | c | c.value.to_s })
|
120
120
|
end
|
121
|
-
|
121
|
+
|
122
122
|
should "have summary on final section for trial balance (which has a blank title)" do
|
123
123
|
section = @report.sections.last
|
124
124
|
summary = section.rows.last
|
@@ -126,7 +126,7 @@ class FactoryTest < Test::Unit::TestCase
|
|
126
126
|
assert_nil(section.title)
|
127
127
|
assert_equal(['Total', '33244.04', '33244.04', '80938.93', '80938.93'], summary.cells.map { | c | c.value.to_s })
|
128
128
|
end
|
129
|
-
|
129
|
+
|
130
130
|
end
|
131
131
|
|
132
132
|
context "report factory in the dirty real world" do
|
@@ -139,7 +139,7 @@ class FactoryTest < Test::Unit::TestCase
|
|
139
139
|
end
|
140
140
|
|
141
141
|
private
|
142
|
-
|
142
|
+
|
143
143
|
def check_valid_report_type(row)
|
144
144
|
case row.type
|
145
145
|
when 'Header' then assert_equal(true, row.header?)
|
@@ -150,5 +150,5 @@ class FactoryTest < Test::Unit::TestCase
|
|
150
150
|
assert(false, "Invalid type: #{row.type}")
|
151
151
|
end
|
152
152
|
end
|
153
|
-
|
153
|
+
|
154
154
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'webmock'
|
3
|
+
|
4
|
+
include WebMock::API
|
5
|
+
WebMock.disable_net_connect!(allow_localhost: true)
|
6
|
+
|
7
|
+
class UnitTestCase < Test::Unit::TestCase
|
8
|
+
def setup
|
9
|
+
WebMock.reset!
|
10
|
+
WebMock.enable!
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown
|
14
|
+
WebMock.disable!
|
15
|
+
end
|
16
|
+
end
|