business-central 1.0.1 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +58 -15
- data/lib/business_central.rb +47 -2
- data/lib/business_central/client.rb +82 -39
- data/lib/business_central/exceptions.rb +30 -10
- data/lib/business_central/object/account.rb +4 -12
- data/lib/business_central/object/aged_account_payable.rb +4 -12
- data/lib/business_central/object/aged_account_receivable.rb +4 -12
- data/lib/business_central/object/argument_helper.rb +22 -0
- data/lib/business_central/object/attachment.rb +30 -0
- data/lib/business_central/object/balance_sheet.rb +4 -12
- data/lib/business_central/object/base.rb +100 -49
- data/lib/business_central/object/cash_flow_statement.rb +4 -12
- data/lib/business_central/object/company.rb +9 -2
- data/lib/business_central/object/company_information.rb +7 -15
- data/lib/business_central/object/country_region.rb +26 -0
- data/lib/business_central/object/currency.rb +29 -0
- data/lib/business_central/object/customer.rb +34 -0
- data/lib/business_central/object/customer_financial_detail.rb +13 -0
- data/lib/business_central/object/customer_payment.rb +43 -0
- data/lib/business_central/object/customer_payment_journal.rb +25 -0
- data/lib/business_central/object/customer_sale.rb +13 -0
- data/lib/business_central/object/default_dimension.rb +51 -0
- data/lib/business_central/object/dimension.rb +20 -0
- data/lib/business_central/object/dimension_line.rb +37 -0
- data/lib/business_central/object/dimension_value.rb +28 -0
- data/lib/business_central/object/employee.rb +21 -0
- data/lib/business_central/object/filter_query.rb +18 -0
- data/lib/business_central/object/general_ledger_entry.rb +13 -0
- data/lib/business_central/object/income_statement.rb +13 -0
- data/lib/business_central/object/irs1099_code.rb +16 -0
- data/lib/business_central/object/item.rb +16 -19
- data/lib/business_central/object/item_category.rb +16 -0
- data/lib/business_central/object/journal.rb +29 -0
- data/lib/business_central/object/journal_line.rb +48 -0
- data/lib/business_central/object/object_helper.rb +49 -0
- data/lib/business_central/object/payment_method.rb +16 -0
- data/lib/business_central/object/payment_term.rb +16 -0
- data/lib/business_central/object/picture.rb +53 -0
- data/lib/business_central/object/purchase_invoice.rb +8 -16
- data/lib/business_central/object/purchase_invoice_line.rb +14 -18
- data/lib/business_central/object/request.rb +61 -50
- data/lib/business_central/object/response.rb +31 -23
- data/lib/business_central/object/retained_earning_statement.rb +13 -0
- data/lib/business_central/object/sales_credit_memo.rb +20 -0
- data/lib/business_central/object/sales_credit_memo_line.rb +30 -0
- data/lib/business_central/object/sales_invoice.rb +62 -0
- data/lib/business_central/object/sales_invoice_line.rb +30 -0
- data/lib/business_central/object/sales_order.rb +20 -0
- data/lib/business_central/object/sales_order_line.rb +30 -0
- data/lib/business_central/object/sales_quote.rb +20 -0
- data/lib/business_central/object/sales_quote_line.rb +30 -0
- data/lib/business_central/object/shipment_method.rb +16 -0
- data/lib/business_central/object/subscription.rb +16 -0
- data/lib/business_central/object/tax_area.rb +16 -0
- data/lib/business_central/object/tax_group.rb +16 -0
- data/lib/business_central/object/time_registration_entry.rb +16 -0
- data/lib/business_central/object/trial_balance.rb +13 -0
- data/lib/business_central/object/units_of_measure.rb +16 -0
- data/lib/business_central/object/url_builder.rb +59 -0
- data/lib/business_central/object/url_helper.rb +44 -0
- data/lib/business_central/object/validation.rb +10 -7
- data/lib/business_central/object/vendor.rb +12 -15
- data/lib/business_central/object/vendor_purchase.rb +13 -0
- data/lib/business_central/version.rb +4 -2
- data/lib/business_central/web_service.rb +78 -0
- data/lib/core_ext/string.rb +18 -12
- data/test/business_central/client_test.rb +49 -7
- data/test/business_central/object/account_test.rb +6 -5
- data/test/business_central/object/aged_account_payable_test.rb +6 -5
- data/test/business_central/object/aged_account_receivable_test.rb +6 -5
- data/test/business_central/object/attachment_test.rb +117 -0
- data/test/business_central/object/balance_sheet_test.rb +6 -5
- data/test/business_central/object/base_test.rb +41 -0
- data/test/business_central/object/cash_flow_statement_test.rb +6 -5
- data/test/business_central/object/company_information_test.rb +9 -10
- data/test/business_central/object/company_test.rb +6 -5
- data/test/business_central/object/country_region_test.rb +129 -0
- data/test/business_central/object/currency_test.rb +150 -0
- data/test/business_central/object/customer_financial_detail_test.rb +68 -0
- data/test/business_central/object/customer_payment_journal_test.rb +134 -0
- data/test/business_central/object/customer_payment_test.rb +141 -0
- data/test/business_central/object/customer_sale_test.rb +72 -0
- data/test/business_central/object/customer_test.rb +168 -0
- data/test/business_central/object/default_dimension_test.rb +170 -0
- data/test/business_central/object/dimension_line_test.rb +165 -0
- data/test/business_central/object/dimension_test.rb +65 -0
- data/test/business_central/object/dimension_value_test.rb +68 -0
- data/test/business_central/object/employee_test.rb +141 -0
- data/test/business_central/object/filter_query_test.rb +36 -0
- data/test/business_central/object/general_ledger_entry_test.rb +82 -0
- data/test/business_central/object/income_statement_test.rb +82 -0
- data/test/business_central/object/irs1099_code_test.rb +124 -0
- data/test/business_central/object/item_category_test.rb +122 -0
- data/test/business_central/object/item_test.rb +16 -17
- data/test/business_central/object/journal_line_test.rb +152 -0
- data/test/business_central/object/journal_test.rb +144 -0
- data/test/business_central/object/payment_method_test.rb +134 -0
- data/test/business_central/object/payment_term_test.rb +134 -0
- data/test/business_central/object/picture_test.rb +74 -0
- data/test/business_central/object/purchase_invoice_line_test.rb +15 -15
- data/test/business_central/object/purchase_invoice_test.rb +15 -15
- data/test/business_central/object/request_test.rb +75 -12
- data/test/business_central/object/response_test.rb +34 -9
- data/test/business_central/object/retained_earning_statement_test.rb +52 -0
- data/test/business_central/object/sales_credit_memo_line_test.rb +134 -0
- data/test/business_central/object/sales_credit_memo_test.rb +146 -0
- data/test/business_central/object/sales_invoice_line_test.rb +164 -0
- data/test/business_central/object/sales_invoice_test.rb +156 -0
- data/test/business_central/object/sales_order_line_test.rb +134 -0
- data/test/business_central/object/sales_order_test.rb +146 -0
- data/test/business_central/object/sales_quote_line_test.rb +134 -0
- data/test/business_central/object/sales_quote_test.rb +146 -0
- data/test/business_central/object/shipment_method_test.rb +133 -0
- data/test/business_central/object/subscription_test.rb +126 -0
- data/test/business_central/object/tax_area_test.rb +126 -0
- data/test/business_central/object/tax_group_test.rb +126 -0
- data/test/business_central/object/time_registration_entry_test.rb +126 -0
- data/test/business_central/object/trial_balance_test.rb +82 -0
- data/test/business_central/object/units_of_measure_test.rb +126 -0
- data/test/business_central/object/validation_test.rb +5 -4
- data/test/business_central/object/vendor_purchase_test.rb +82 -0
- data/test/business_central/object/vendor_test.rb +16 -16
- data/test/business_central/web_service_test.rb +100 -0
- data/test/business_central_test.rb +3 -1
- data/test/test_helper.rb +16 -6
- metadata +188 -37
- data/lib/business_central/object/helper.rb +0 -15
@@ -0,0 +1,146 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
# rake test TEST=test/business_central/object/sales_quote_test.rb
|
5
|
+
|
6
|
+
class BusinessCentral::Object::SalesQuoteTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
@company_id = '123456'
|
9
|
+
@client = BusinessCentral::Client.new
|
10
|
+
@sales_quote = @client.sales_quote(company_id: @company_id)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_find_all
|
14
|
+
stub_request(:get, /salesQuotes/)
|
15
|
+
.to_return(
|
16
|
+
status: 200,
|
17
|
+
body: {
|
18
|
+
'value': [
|
19
|
+
{
|
20
|
+
id: 1,
|
21
|
+
number: '1009'
|
22
|
+
}
|
23
|
+
]
|
24
|
+
}.to_json
|
25
|
+
)
|
26
|
+
|
27
|
+
response = @sales_quote.find_all
|
28
|
+
assert_equal response.first[:number], '1009'
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_find_by_id
|
32
|
+
test_id = '09876'
|
33
|
+
stub_request(:get, /salesQuotes\(#{test_id}\)/)
|
34
|
+
.to_return(
|
35
|
+
status: 200,
|
36
|
+
body: {
|
37
|
+
id: test_id,
|
38
|
+
number: '1010'
|
39
|
+
}.to_json
|
40
|
+
)
|
41
|
+
|
42
|
+
response = @sales_quote.find_by_id(test_id)
|
43
|
+
assert_equal response[:number], '1010'
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_where
|
47
|
+
test_filter = "number eq '1020'"
|
48
|
+
stub_request(:get, /salesQuotes\?\$filter=#{test_filter}/)
|
49
|
+
.to_return(
|
50
|
+
status: 200,
|
51
|
+
body: {
|
52
|
+
'value': [
|
53
|
+
{
|
54
|
+
id: '345',
|
55
|
+
number: '1011'
|
56
|
+
}
|
57
|
+
]
|
58
|
+
}.to_json
|
59
|
+
)
|
60
|
+
|
61
|
+
response = @sales_quote.where(test_filter)
|
62
|
+
assert_equal response.first[:number], '1011'
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_create
|
66
|
+
stub_request(:post, /salesQuotes/)
|
67
|
+
.to_return(
|
68
|
+
status: 200,
|
69
|
+
body: {
|
70
|
+
id: '678',
|
71
|
+
number: '1012'
|
72
|
+
}.to_json
|
73
|
+
)
|
74
|
+
|
75
|
+
response = @sales_quote.create(
|
76
|
+
number: '1012'
|
77
|
+
)
|
78
|
+
assert_equal response[:number], '1012'
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_update
|
82
|
+
test_id = '011123'
|
83
|
+
stub_request(:get, /salesQuotes\(#{test_id}\)/)
|
84
|
+
.to_return(
|
85
|
+
status: 200,
|
86
|
+
body: {
|
87
|
+
etag: '112',
|
88
|
+
id: test_id,
|
89
|
+
number: '1012'
|
90
|
+
}.to_json
|
91
|
+
)
|
92
|
+
|
93
|
+
stub_request(:patch, /salesQuotes\(#{test_id}\)/)
|
94
|
+
.to_return(
|
95
|
+
status: 200,
|
96
|
+
body: {
|
97
|
+
id: test_id,
|
98
|
+
number: '1013'
|
99
|
+
}.to_json
|
100
|
+
)
|
101
|
+
|
102
|
+
response = @sales_quote.update(
|
103
|
+
test_id,
|
104
|
+
number: '1013'
|
105
|
+
)
|
106
|
+
assert_equal response[:number], '1013'
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_delete
|
110
|
+
test_id = '0111245'
|
111
|
+
stub_request(:get, /salesQuotes\(#{test_id}\)/)
|
112
|
+
.to_return(
|
113
|
+
status: 200,
|
114
|
+
body: {
|
115
|
+
etag: '113',
|
116
|
+
id: 7,
|
117
|
+
number: '1013'
|
118
|
+
}.to_json
|
119
|
+
)
|
120
|
+
|
121
|
+
stub_request(:delete, /salesQuotes\(#{test_id}\)/)
|
122
|
+
.to_return(status: 204)
|
123
|
+
|
124
|
+
assert @sales_quote.destroy(test_id)
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_line_navigation
|
128
|
+
stub_request(:get, %r{salesQuotes\(\d+\)\/salesQuoteLines})
|
129
|
+
.to_return(
|
130
|
+
status: 200,
|
131
|
+
body: {
|
132
|
+
'value': [
|
133
|
+
{
|
134
|
+
id: 1,
|
135
|
+
sequence: '1009',
|
136
|
+
lineType: 'Comment'
|
137
|
+
}
|
138
|
+
]
|
139
|
+
}.to_json
|
140
|
+
)
|
141
|
+
|
142
|
+
response = @client.sales_quote(company_id: @company_id, id: '123')
|
143
|
+
.sales_quote_line.find_all
|
144
|
+
assert_equal response.first[:sequence], '1009'
|
145
|
+
end
|
146
|
+
end
|
@@ -0,0 +1,133 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
# rake test TEST=test/business_central/object/shipment_method_test.rb
|
5
|
+
|
6
|
+
class BusinessCentral::Object::ShipmentMethodTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
@company_id = '123456'
|
9
|
+
@client = BusinessCentral::Client.new
|
10
|
+
@shipment_method = @client.shipment_method(company_id: @company_id)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_find_all
|
14
|
+
stub_request(:get, /shipmentMethods/)
|
15
|
+
.to_return(
|
16
|
+
status: 200,
|
17
|
+
body: {
|
18
|
+
'value': [
|
19
|
+
{
|
20
|
+
id: 1,
|
21
|
+
code: '1001',
|
22
|
+
displayName: 'shippingMethod1'
|
23
|
+
}
|
24
|
+
]
|
25
|
+
}.to_json
|
26
|
+
)
|
27
|
+
|
28
|
+
response = @shipment_method.find_all
|
29
|
+
assert_equal response.first[:display_name], 'shippingMethod1'
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_find_by_id
|
33
|
+
test_id = '09876'
|
34
|
+
stub_request(:get, /shipmentMethods\(#{test_id}\)/)
|
35
|
+
.to_return(
|
36
|
+
status: 200,
|
37
|
+
body: {
|
38
|
+
id: test_id,
|
39
|
+
code: '1002',
|
40
|
+
displayName: 'shippingMethod2'
|
41
|
+
}.to_json
|
42
|
+
)
|
43
|
+
|
44
|
+
response = @shipment_method.find_by_id(test_id)
|
45
|
+
assert_equal response[:display_name], 'shippingMethod2'
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_where
|
49
|
+
test_filter = "number eq '1020'"
|
50
|
+
stub_request(:get, /shipmentMethods\?\$filter=#{test_filter}/)
|
51
|
+
.to_return(
|
52
|
+
status: 200,
|
53
|
+
body: {
|
54
|
+
'value': [
|
55
|
+
{
|
56
|
+
id: '345',
|
57
|
+
code: '1003',
|
58
|
+
displayName: 'shippingMethod3'
|
59
|
+
}
|
60
|
+
]
|
61
|
+
}.to_json
|
62
|
+
)
|
63
|
+
|
64
|
+
response = @shipment_method.where(test_filter)
|
65
|
+
assert_equal response.first[:display_name], 'shippingMethod3'
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_create
|
69
|
+
stub_request(:post, /shipmentMethods/)
|
70
|
+
.to_return(
|
71
|
+
status: 200,
|
72
|
+
body: {
|
73
|
+
id: '678',
|
74
|
+
code: '1003',
|
75
|
+
displayName: 'shippingMethod3'
|
76
|
+
}.to_json
|
77
|
+
)
|
78
|
+
|
79
|
+
response = @shipment_method.create(
|
80
|
+
display_name: 'shippingMethod3'
|
81
|
+
)
|
82
|
+
assert_equal response[:display_name], 'shippingMethod3'
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_update
|
86
|
+
test_id = '011123'
|
87
|
+
stub_request(:get, /shipmentMethods\(#{test_id}\)/)
|
88
|
+
.to_return(
|
89
|
+
status: 200,
|
90
|
+
body: {
|
91
|
+
etag: '112',
|
92
|
+
id: test_id,
|
93
|
+
code: '1004',
|
94
|
+
displayName: 'shippingMethod4'
|
95
|
+
}.to_json
|
96
|
+
)
|
97
|
+
|
98
|
+
stub_request(:patch, /shipmentMethods\(#{test_id}\)/)
|
99
|
+
.to_return(
|
100
|
+
status: 200,
|
101
|
+
body: {
|
102
|
+
id: test_id,
|
103
|
+
code: '1004',
|
104
|
+
displayName: 'shippingMethod4_1'
|
105
|
+
}.to_json
|
106
|
+
)
|
107
|
+
|
108
|
+
response = @shipment_method.update(
|
109
|
+
test_id,
|
110
|
+
display_name: 'shippingMethod4_1'
|
111
|
+
)
|
112
|
+
assert_equal response[:display_name], 'shippingMethod4_1'
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_delete
|
116
|
+
test_id = '0111245'
|
117
|
+
stub_request(:get, /shipmentMethods\(#{test_id}\)/)
|
118
|
+
.to_return(
|
119
|
+
status: 200,
|
120
|
+
body: {
|
121
|
+
etag: '113',
|
122
|
+
id: test_id,
|
123
|
+
code: '1005',
|
124
|
+
displayName: 'shippingMethod5'
|
125
|
+
}.to_json
|
126
|
+
)
|
127
|
+
|
128
|
+
stub_request(:delete, /shipmentMethods\(#{test_id}\)/)
|
129
|
+
.to_return(status: 204)
|
130
|
+
|
131
|
+
assert @shipment_method.destroy(test_id)
|
132
|
+
end
|
133
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
# rake test TEST=test/business_central/object/subscription_test.rb
|
5
|
+
|
6
|
+
class BusinessCentral::Object::SubscriptionTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
@company_id = '123456'
|
9
|
+
@client = BusinessCentral::Client.new
|
10
|
+
@subscription = @client.subscription(company_id: @company_id)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_find_all
|
14
|
+
stub_request(:get, /subscriptions/)
|
15
|
+
.to_return(
|
16
|
+
status: 200,
|
17
|
+
body: {
|
18
|
+
'value': [
|
19
|
+
{
|
20
|
+
id: 1,
|
21
|
+
number: '1009'
|
22
|
+
}
|
23
|
+
]
|
24
|
+
}.to_json
|
25
|
+
)
|
26
|
+
|
27
|
+
response = @subscription.find_all
|
28
|
+
assert_equal response.first[:number], '1009'
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_find_by_id
|
32
|
+
test_id = '09876'
|
33
|
+
stub_request(:get, /subscriptions\(#{test_id}\)/)
|
34
|
+
.to_return(
|
35
|
+
status: 200,
|
36
|
+
body: {
|
37
|
+
id: test_id,
|
38
|
+
number: '1010'
|
39
|
+
}.to_json
|
40
|
+
)
|
41
|
+
|
42
|
+
response = @subscription.find_by_id(test_id)
|
43
|
+
assert_equal response[:number], '1010'
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_where
|
47
|
+
test_filter = "number eq '1020'"
|
48
|
+
stub_request(:get, /subscriptions\?\$filter=#{test_filter}/)
|
49
|
+
.to_return(
|
50
|
+
status: 200,
|
51
|
+
body: {
|
52
|
+
'value': [
|
53
|
+
{
|
54
|
+
id: '345',
|
55
|
+
number: '1011'
|
56
|
+
}
|
57
|
+
]
|
58
|
+
}.to_json
|
59
|
+
)
|
60
|
+
|
61
|
+
response = @subscription.where(test_filter)
|
62
|
+
assert_equal response.first[:number], '1011'
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_create
|
66
|
+
stub_request(:post, /subscriptions/)
|
67
|
+
.to_return(
|
68
|
+
status: 200,
|
69
|
+
body: {
|
70
|
+
id: '678',
|
71
|
+
number: '1012'
|
72
|
+
}.to_json
|
73
|
+
)
|
74
|
+
|
75
|
+
response = @subscription.create(
|
76
|
+
number: '1012'
|
77
|
+
)
|
78
|
+
assert_equal response[:number], '1012'
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_update
|
82
|
+
test_id = '011123'
|
83
|
+
stub_request(:get, /subscriptions\(#{test_id}\)/)
|
84
|
+
.to_return(
|
85
|
+
status: 200,
|
86
|
+
body: {
|
87
|
+
etag: '112',
|
88
|
+
id: test_id,
|
89
|
+
number: '1012'
|
90
|
+
}.to_json
|
91
|
+
)
|
92
|
+
|
93
|
+
stub_request(:patch, /subscriptions\(#{test_id}\)/)
|
94
|
+
.to_return(
|
95
|
+
status: 200,
|
96
|
+
body: {
|
97
|
+
id: test_id,
|
98
|
+
number: '1013'
|
99
|
+
}.to_json
|
100
|
+
)
|
101
|
+
|
102
|
+
response = @subscription.update(
|
103
|
+
test_id,
|
104
|
+
number: '1013'
|
105
|
+
)
|
106
|
+
assert_equal response[:number], '1013'
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_delete
|
110
|
+
test_id = '0111245'
|
111
|
+
stub_request(:get, /subscriptions\(#{test_id}\)/)
|
112
|
+
.to_return(
|
113
|
+
status: 200,
|
114
|
+
body: {
|
115
|
+
etag: '113',
|
116
|
+
id: test_id,
|
117
|
+
number: '1013'
|
118
|
+
}.to_json
|
119
|
+
)
|
120
|
+
|
121
|
+
stub_request(:delete, /subscriptions\(#{test_id}\)/)
|
122
|
+
.to_return(status: 204)
|
123
|
+
|
124
|
+
assert @subscription.destroy(test_id)
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
# rake test TEST=test/business_central/object/tax_area_test.rb
|
5
|
+
|
6
|
+
class BusinessCentral::Object::TaxAreaTest < Minitest::Test
|
7
|
+
def setup
|
8
|
+
@company_id = '123456'
|
9
|
+
@client = BusinessCentral::Client.new
|
10
|
+
@tax_area = @client.tax_area(company_id: @company_id)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_find_all
|
14
|
+
stub_request(:get, /taxAreas/)
|
15
|
+
.to_return(
|
16
|
+
status: 200,
|
17
|
+
body: {
|
18
|
+
'value': [
|
19
|
+
{
|
20
|
+
id: 1,
|
21
|
+
number: '1009'
|
22
|
+
}
|
23
|
+
]
|
24
|
+
}.to_json
|
25
|
+
)
|
26
|
+
|
27
|
+
response = @tax_area.find_all
|
28
|
+
assert_equal response.first[:number], '1009'
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_find_by_id
|
32
|
+
test_id = '09876'
|
33
|
+
stub_request(:get, /taxAreas\(#{test_id}\)/)
|
34
|
+
.to_return(
|
35
|
+
status: 200,
|
36
|
+
body: {
|
37
|
+
id: test_id,
|
38
|
+
number: '1010'
|
39
|
+
}.to_json
|
40
|
+
)
|
41
|
+
|
42
|
+
response = @tax_area.find_by_id(test_id)
|
43
|
+
assert_equal response[:number], '1010'
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_where
|
47
|
+
test_filter = "number eq '1020'"
|
48
|
+
stub_request(:get, /taxAreas\?\$filter=#{test_filter}/)
|
49
|
+
.to_return(
|
50
|
+
status: 200,
|
51
|
+
body: {
|
52
|
+
'value': [
|
53
|
+
{
|
54
|
+
id: '345',
|
55
|
+
number: '1011'
|
56
|
+
}
|
57
|
+
]
|
58
|
+
}.to_json
|
59
|
+
)
|
60
|
+
|
61
|
+
response = @tax_area.where(test_filter)
|
62
|
+
assert_equal response.first[:number], '1011'
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_create
|
66
|
+
stub_request(:post, /taxAreas/)
|
67
|
+
.to_return(
|
68
|
+
status: 200,
|
69
|
+
body: {
|
70
|
+
id: '678',
|
71
|
+
number: '1012'
|
72
|
+
}.to_json
|
73
|
+
)
|
74
|
+
|
75
|
+
response = @tax_area.create(
|
76
|
+
number: '1012'
|
77
|
+
)
|
78
|
+
assert_equal response[:number], '1012'
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_update
|
82
|
+
test_id = '011123'
|
83
|
+
stub_request(:get, /taxAreas\(#{test_id}\)/)
|
84
|
+
.to_return(
|
85
|
+
status: 200,
|
86
|
+
body: {
|
87
|
+
etag: '112',
|
88
|
+
id: test_id,
|
89
|
+
number: '1012'
|
90
|
+
}.to_json
|
91
|
+
)
|
92
|
+
|
93
|
+
stub_request(:patch, /taxAreas\(#{test_id}\)/)
|
94
|
+
.to_return(
|
95
|
+
status: 200,
|
96
|
+
body: {
|
97
|
+
id: test_id,
|
98
|
+
number: '1013'
|
99
|
+
}.to_json
|
100
|
+
)
|
101
|
+
|
102
|
+
response = @tax_area.update(
|
103
|
+
test_id,
|
104
|
+
number: '1013'
|
105
|
+
)
|
106
|
+
assert_equal response[:number], '1013'
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_delete
|
110
|
+
test_id = '0111245'
|
111
|
+
stub_request(:get, /taxAreas\(#{test_id}\)/)
|
112
|
+
.to_return(
|
113
|
+
status: 200,
|
114
|
+
body: {
|
115
|
+
etag: '113',
|
116
|
+
id: test_id,
|
117
|
+
number: '1013'
|
118
|
+
}.to_json
|
119
|
+
)
|
120
|
+
|
121
|
+
stub_request(:delete, /taxAreas\(#{test_id}\)/)
|
122
|
+
.to_return(status: 204)
|
123
|
+
|
124
|
+
assert @tax_area.destroy(test_id)
|
125
|
+
end
|
126
|
+
end
|