my_john_deere_api 2.5.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/my_john_deere_api.rb +1 -1
- data/lib/my_john_deere_api/authorize.rb +36 -27
- data/lib/my_john_deere_api/client.rb +38 -29
- data/lib/my_john_deere_api/consumer.rb +46 -35
- data/lib/my_john_deere_api/helpers/case_conversion.rb +5 -2
- data/lib/my_john_deere_api/helpers/uri_helpers.rb +1 -1
- data/lib/my_john_deere_api/model/contribution_definition.rb +1 -1
- data/lib/my_john_deere_api/net_http_retry/decorator.rb +10 -11
- data/lib/my_john_deere_api/net_http_retry/invalid_response_error.rb +2 -2
- data/lib/my_john_deere_api/request/collection/asset_locations.rb +1 -1
- data/lib/my_john_deere_api/request/collection/assets.rb +1 -1
- data/lib/my_john_deere_api/request/collection/base.rb +2 -14
- data/lib/my_john_deere_api/request/collection/contribution_definitions.rb +1 -1
- data/lib/my_john_deere_api/request/collection/contribution_products.rb +1 -1
- data/lib/my_john_deere_api/request/collection/fields.rb +1 -1
- data/lib/my_john_deere_api/request/collection/flags.rb +1 -1
- data/lib/my_john_deere_api/request/collection/organizations.rb +1 -1
- data/lib/my_john_deere_api/request/create/asset.rb +8 -11
- data/lib/my_john_deere_api/request/create/asset_location.rb +24 -25
- data/lib/my_john_deere_api/request/create/base.rb +2 -20
- data/lib/my_john_deere_api/request/individual/asset.rb +2 -2
- data/lib/my_john_deere_api/request/individual/base.rb +6 -24
- data/lib/my_john_deere_api/request/individual/contribution_definition.rb +1 -1
- data/lib/my_john_deere_api/request/individual/contribution_product.rb +1 -1
- data/lib/my_john_deere_api/request/individual/field.rb +1 -1
- data/lib/my_john_deere_api/request/individual/organization.rb +1 -1
- data/lib/my_john_deere_api/request/update/asset.rb +2 -2
- data/lib/my_john_deere_api/request/update/base.rb +1 -19
- data/lib/my_john_deere_api/version.rb +1 -1
- data/test/lib/my_john_deere_api/authorize_test.rb +37 -25
- data/test/lib/my_john_deere_api/client_test.rb +22 -56
- data/test/lib/my_john_deere_api/consumer_test.rb +16 -28
- data/test/lib/my_john_deere_api/helpers/uri_helpers_test.rb +0 -10
- data/test/lib/my_john_deere_api/model/asset_location_test.rb +0 -4
- data/test/lib/my_john_deere_api/model/asset_test.rb +9 -8
- data/test/lib/my_john_deere_api/model/base_test.rb +4 -8
- data/test/lib/my_john_deere_api/model/contribution_definition_test.rb +3 -7
- data/test/lib/my_john_deere_api/model/contribution_product_test.rb +4 -7
- data/test/lib/my_john_deere_api/model/field_test.rb +4 -6
- data/test/lib/my_john_deere_api/model/flag_test.rb +6 -7
- data/test/lib/my_john_deere_api/model/organization_test.rb +3 -5
- data/test/lib/my_john_deere_api/net_http_retry/decorator_test.rb +14 -14
- data/test/lib/my_john_deere_api/net_http_retry/invalid_response_error_test.rb +22 -2
- data/test/lib/my_john_deere_api/request/collection/asset_locations_test.rb +2 -2
- data/test/lib/my_john_deere_api/request/collection/assets_test.rb +2 -2
- data/test/lib/my_john_deere_api/request/collection/contribution_definitions_test.rb +2 -2
- data/test/lib/my_john_deere_api/request/collection/contribution_products_test.rb +2 -2
- data/test/lib/my_john_deere_api/request/collection/fields_test.rb +2 -2
- data/test/lib/my_john_deere_api/request/collection/flags_test.rb +2 -2
- data/test/lib/my_john_deere_api/request/collection/organizations_test.rb +2 -2
- data/test/lib/my_john_deere_api/request/create/asset_location_test.rb +3 -2
- data/test/lib/my_john_deere_api/request/create/asset_test.rb +5 -4
- data/test/lib/my_john_deere_api/request/create/base_test.rb +0 -14
- data/test/lib/my_john_deere_api/request/individual/asset_test.rb +2 -3
- data/test/lib/my_john_deere_api/request/individual/base_test.rb +0 -1
- data/test/lib/my_john_deere_api/request/individual/contribution_definition_test.rb +2 -3
- data/test/lib/my_john_deere_api/request/individual/contribution_product_test.rb +2 -3
- data/test/lib/my_john_deere_api/request/individual/field_test.rb +2 -3
- data/test/lib/my_john_deere_api/request/individual/organization_test.rb +2 -3
- data/test/lib/my_john_deere_api/request/update/asset_test.rb +5 -17
- data/test/lib/my_john_deere_api/request/update/base_test.rb +0 -14
- data/test/support/helper.rb +14 -5
- data/test/support/link_helpers.rb +14 -0
- data/test/support/response_helpers.rb +18 -0
- data/test/support/vcr/catalog.yml +44 -37
- data/test/support/vcr/get_access_token.yml +90 -17
- data/test/support/vcr/get_refresh_token.yml +159 -0
- data/test/support/vcr/get_request_url.yml +51 -0
- data/test/support/vcr_setup.rb +80 -19
- metadata +11 -8
- data/test/support/vcr/get_request_token.yml +0 -83
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'support/helper'
|
2
2
|
|
3
3
|
describe 'MyJohnDeereApi::Model::ContributionProduct' do
|
4
|
+
include JD::LinkHelpers
|
5
|
+
|
4
6
|
let(:klass) { JD::Model::ContributionProduct }
|
5
7
|
|
6
8
|
let(:record) do
|
@@ -32,14 +34,9 @@ describe 'MyJohnDeereApi::Model::ContributionProduct' do
|
|
32
34
|
end
|
33
35
|
|
34
36
|
describe '#initialize' do
|
35
|
-
def link_for label
|
36
|
-
camel_label = label.gsub(/_(.)/){|m| m[1].upcase}
|
37
|
-
record['links'].detect{|link| link['rel'] == camel_label}['uri'].gsub('https://sandboxapi.deere.com/platform', '')
|
38
|
-
end
|
39
|
-
|
40
37
|
it 'sets the attributes from the given record' do
|
41
38
|
product = klass.new(client, record)
|
42
|
-
|
39
|
+
|
43
40
|
assert_equal client, product.client
|
44
41
|
assert_equal accessor, product.accessor
|
45
42
|
|
@@ -59,7 +56,7 @@ describe 'MyJohnDeereApi::Model::ContributionProduct' do
|
|
59
56
|
product = klass.new(client, record)
|
60
57
|
|
61
58
|
['self', 'contribution_definition'].each do |association|
|
62
|
-
|
59
|
+
assert_link_for product, association
|
63
60
|
end
|
64
61
|
end
|
65
62
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'support/helper'
|
2
2
|
|
3
3
|
describe 'MyJohnDeereApi::Model::Field' do
|
4
|
+
include JD::LinkHelpers
|
5
|
+
|
4
6
|
let(:klass) { JD::Model::Field }
|
5
7
|
|
6
8
|
let(:record) do
|
@@ -18,10 +20,6 @@ describe 'MyJohnDeereApi::Model::Field' do
|
|
18
20
|
end
|
19
21
|
|
20
22
|
describe '#initialize' do
|
21
|
-
def link_for label
|
22
|
-
record['links'].detect{|link| link['rel'] == label}['uri'].gsub('https://sandboxapi.deere.com/platform', '')
|
23
|
-
end
|
24
|
-
|
25
23
|
it 'sets the attributes from the given record' do
|
26
24
|
field = klass.new(client, record)
|
27
25
|
|
@@ -36,8 +34,8 @@ describe 'MyJohnDeereApi::Model::Field' do
|
|
36
34
|
# links to other things
|
37
35
|
assert_kind_of Hash, field.links
|
38
36
|
|
39
|
-
[
|
40
|
-
|
37
|
+
[:clients, :notes].each do |association|
|
38
|
+
assert_link_for field, association
|
41
39
|
end
|
42
40
|
end
|
43
41
|
end
|
@@ -2,6 +2,8 @@ require 'support/helper'
|
|
2
2
|
require 'json'
|
3
3
|
|
4
4
|
describe 'MyJohnDeereApi::Model::Flag' do
|
5
|
+
include JD::LinkHelpers
|
6
|
+
|
5
7
|
let(:klass) { JD::Model::Flag }
|
6
8
|
|
7
9
|
let(:record) do
|
@@ -21,10 +23,6 @@ describe 'MyJohnDeereApi::Model::Flag' do
|
|
21
23
|
end
|
22
24
|
|
23
25
|
describe '#initialize' do
|
24
|
-
def link_for label
|
25
|
-
record['links'].detect{|link| link['rel'] == label}['uri'].gsub('https://sandboxapi.deere.com/platform', '')
|
26
|
-
end
|
27
|
-
|
28
26
|
it 'sets the attributes from the given record' do
|
29
27
|
flag = klass.new(client, record)
|
30
28
|
|
@@ -40,9 +38,10 @@ describe 'MyJohnDeereApi::Model::Flag' do
|
|
40
38
|
|
41
39
|
# links to other things
|
42
40
|
assert_kind_of Hash, flag.links
|
43
|
-
|
44
|
-
|
45
|
-
|
41
|
+
|
42
|
+
[:field, :created_by, :last_modified_by].each do |attribute|
|
43
|
+
assert_link_for(flag, attribute)
|
44
|
+
end
|
46
45
|
end
|
47
46
|
end
|
48
47
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'support/helper'
|
2
2
|
|
3
3
|
describe 'MyJohnDeereApi::Model::Organization' do
|
4
|
+
include JD::LinkHelpers
|
5
|
+
|
4
6
|
let(:klass) { JD::Model::Organization }
|
5
7
|
|
6
8
|
let(:record) do
|
@@ -31,10 +33,6 @@ describe 'MyJohnDeereApi::Model::Organization' do
|
|
31
33
|
end
|
32
34
|
|
33
35
|
describe '#initialize(record, client = nil)' do
|
34
|
-
def link_for label
|
35
|
-
record['links'].detect{|link| link['rel'] == label}['uri'].gsub('https://sandboxapi.deere.com/platform', '')
|
36
|
-
end
|
37
|
-
|
38
36
|
it 'sets the attributes from the given record' do
|
39
37
|
organization = klass.new(client, record)
|
40
38
|
|
@@ -51,7 +49,7 @@ describe 'MyJohnDeereApi::Model::Organization' do
|
|
51
49
|
assert_kind_of Hash, organization.links
|
52
50
|
|
53
51
|
['fields', 'machines', 'files', 'assets', 'farms', 'boundaries', 'clients', 'controllers'].each do |association|
|
54
|
-
|
52
|
+
assert_link_for(organization, association)
|
55
53
|
end
|
56
54
|
end
|
57
55
|
end
|
@@ -2,10 +2,10 @@ require 'support/helper'
|
|
2
2
|
|
3
3
|
describe 'JD::NetHttpRetry::Decorator' do
|
4
4
|
REQUESTS = {
|
5
|
-
get: '/',
|
6
|
-
post: '/organizations/000000/assets',
|
7
|
-
put: '/assets/00000000-0000-0000-0000-000000000000',
|
8
|
-
delete: '/assets/00000000-0000-0000-0000-000000000000'
|
5
|
+
get: '/platform/',
|
6
|
+
post: '/platform/organizations/000000/assets',
|
7
|
+
put: '/platform/assets/00000000-0000-0000-0000-000000000000',
|
8
|
+
delete: '/platform/assets/00000000-0000-0000-0000-000000000000'
|
9
9
|
}
|
10
10
|
|
11
11
|
REQUEST_METHODS = REQUESTS.keys
|
@@ -33,7 +33,7 @@ describe 'JD::NetHttpRetry::Decorator' do
|
|
33
33
|
let(:exponential_retries) { (0..klass::DEFAULTS[:max_retries]-1).map{|i| 2 ** i} }
|
34
34
|
|
35
35
|
it 'wraps a "net-http"-responsive object' do
|
36
|
-
assert_kind_of
|
36
|
+
assert_kind_of OAuth2::AccessToken, accessor.object
|
37
37
|
end
|
38
38
|
|
39
39
|
describe '#initialize' do
|
@@ -82,16 +82,16 @@ describe 'JD::NetHttpRetry::Decorator' do
|
|
82
82
|
describe 'when retry_codes are specified' do
|
83
83
|
let(:retry_codes) { ['200', '201'] }
|
84
84
|
|
85
|
-
it 'uses the supplied values' do
|
86
|
-
assert_equal retry_codes, object.retry_codes
|
85
|
+
it 'uses the integer versions of the supplied values' do
|
86
|
+
assert_equal retry_codes.map(&:to_i), object.retry_codes
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
90
|
describe 'when retry_codes are specified as integers' do
|
91
91
|
let(:retry_codes) { [200, 201] }
|
92
92
|
|
93
|
-
it 'uses the
|
94
|
-
assert_equal retry_codes
|
93
|
+
it 'uses the supplied values' do
|
94
|
+
assert_equal retry_codes, object.retry_codes
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
@@ -104,16 +104,16 @@ describe 'JD::NetHttpRetry::Decorator' do
|
|
104
104
|
describe 'when valid_codes are specified' do
|
105
105
|
let(:valid_codes) { ['123', '234'] }
|
106
106
|
|
107
|
-
it 'uses the supplied values' do
|
108
|
-
assert_equal valid_codes, object.valid_codes
|
107
|
+
it 'uses the integer versions of the supplied values' do
|
108
|
+
assert_equal valid_codes.map(&:to_i), object.valid_codes
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
112
112
|
describe 'when valid_codes are specified as integers' do
|
113
113
|
let(:valid_codes) { [123, 234] }
|
114
114
|
|
115
|
-
it 'uses the
|
116
|
-
assert_equal valid_codes
|
115
|
+
it 'uses the supplied values' do
|
116
|
+
assert_equal valid_codes, object.valid_codes
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
@@ -199,7 +199,7 @@ describe 'JD::NetHttpRetry::Decorator' do
|
|
199
199
|
|
200
200
|
exception_json = JSON.parse(exception.message)
|
201
201
|
|
202
|
-
assert_equal
|
202
|
+
assert_equal 500, exception_json['code']
|
203
203
|
assert_equal 'Internal Error', exception_json['message']
|
204
204
|
assert_equal 'You Have Died of Dysentery', exception_json['body']
|
205
205
|
end
|
@@ -3,7 +3,22 @@ require 'support/helper'
|
|
3
3
|
describe 'JD::NetHttpRetry::InvalidResponseError' do
|
4
4
|
let(:klass) { JD::NetHttpRetry::InvalidResponseError }
|
5
5
|
let(:response) { stub(response_content) }
|
6
|
-
|
6
|
+
|
7
|
+
let(:faraday_response) do
|
8
|
+
stub(
|
9
|
+
status: '123',
|
10
|
+
reason_phrase: 'failed',
|
11
|
+
body: 'body'
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:response_content) do
|
16
|
+
{
|
17
|
+
status: faraday_response.status,
|
18
|
+
body: faraday_response.body,
|
19
|
+
response: faraday_response
|
20
|
+
}
|
21
|
+
end
|
7
22
|
|
8
23
|
it 'inherits from StandardError' do
|
9
24
|
error = klass.new(response)
|
@@ -11,7 +26,12 @@ describe 'JD::NetHttpRetry::InvalidResponseError' do
|
|
11
26
|
end
|
12
27
|
|
13
28
|
it 'accepts a response object, and includes pertinent info' do
|
14
|
-
expected_message =
|
29
|
+
expected_message = {
|
30
|
+
code: faraday_response.status,
|
31
|
+
message: faraday_response.reason_phrase,
|
32
|
+
body: faraday_response.body
|
33
|
+
}.to_json
|
34
|
+
|
15
35
|
actual_message = klass.new(response).message
|
16
36
|
|
17
37
|
assert_equal expected_message, actual_message
|
@@ -23,8 +23,8 @@ describe 'MyJohnDeereApi::Request::Collection::AssetLocations' do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
describe '#resource' do
|
26
|
-
it 'returns /assets/{asset_id}/locations' do
|
27
|
-
assert_equal "/assets/#{asset_id}/locations", collection.resource
|
26
|
+
it 'returns /platform/assets/{asset_id}/locations' do
|
27
|
+
assert_equal "/platform/assets/#{asset_id}/locations", collection.resource
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -23,8 +23,8 @@ describe 'MyJohnDeereApi::Request::Collection::Assets' do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
describe '#resource' do
|
26
|
-
it 'returns /organizations/{org_id}/assets' do
|
27
|
-
assert_equal "/organizations/#{organization_id}/assets", collection.resource
|
26
|
+
it 'returns /platform/organizations/{org_id}/assets' do
|
27
|
+
assert_equal "/platform/organizations/#{organization_id}/assets", collection.resource
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -24,8 +24,8 @@ describe 'MyJohnDeereApi::Request::Collection::ContributionDefinitions' do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
describe '#resource' do
|
27
|
-
it 'returns /contributionProducts/<contribution_product_id>/contributionDefinitions' do
|
28
|
-
assert_equal "/contributionProducts/#{contribution_product_id}/contributionDefinitions", collection.resource
|
27
|
+
it 'returns /platform/contributionProducts/<contribution_product_id>/contributionDefinitions' do
|
28
|
+
assert_equal "/platform/contributionProducts/#{contribution_product_id}/contributionDefinitions", collection.resource
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -24,8 +24,8 @@ describe 'MyJohnDeereApi::Request::Collection::ContributionProducts' do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
describe '#resource' do
|
27
|
-
it 'returns /contributionProducts' do
|
28
|
-
assert_equal "/contributionProducts?clientControlled=true", collection.resource
|
27
|
+
it 'returns /platform/contributionProducts' do
|
28
|
+
assert_equal "/platform/contributionProducts?clientControlled=true", collection.resource
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -23,8 +23,8 @@ describe 'MyJohnDeereApi::Request::Collection::Fields' do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
describe '#resource' do
|
26
|
-
it 'returns /organizations/{org_id}/fields' do
|
27
|
-
assert_equal "/organizations/#{organization_id}/fields", collection.resource
|
26
|
+
it 'returns /platform/organizations/{org_id}/fields' do
|
27
|
+
assert_equal "/platform/organizations/#{organization_id}/fields", collection.resource
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -24,8 +24,8 @@ describe 'MyJohnDeereApi::Request::Collection::Flags' do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
describe '#resource' do
|
27
|
-
it 'returns /organizations/{org_id}/fields/{field_id}/flags' do
|
28
|
-
assert_equal "/organizations/#{organization_id}/fields/#{field_id}/flags", collection.resource
|
27
|
+
it 'returns /platform/organizations/{org_id}/fields/{field_id}/flags' do
|
28
|
+
assert_equal "/platform/organizations/#{organization_id}/fields/#{field_id}/flags", collection.resource
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -16,8 +16,8 @@ describe 'MyJohnDeereApi::Request::Collection::Organizations' do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
describe '#resource' do
|
19
|
-
it 'returns /organization' do
|
20
|
-
assert_equal '/organizations', collection.resource
|
19
|
+
it 'returns /platform/organization' do
|
20
|
+
assert_equal '/platform/organizations', collection.resource
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -2,6 +2,8 @@ require 'support/helper'
|
|
2
2
|
require 'date'
|
3
3
|
|
4
4
|
describe 'MyJohnDeereApi::Request::Create::AssetLocation' do
|
5
|
+
include JD::ResponseHelpers
|
6
|
+
|
5
7
|
def attributes_without(*keys)
|
6
8
|
keys = keys.to_a
|
7
9
|
attributes.reject{|k,v| keys.include?(k)}
|
@@ -23,7 +25,6 @@ describe 'MyJohnDeereApi::Request::Create::AssetLocation' do
|
|
23
25
|
describe '#initialize(client, attributes)' do
|
24
26
|
it 'accepts a client and attributes' do
|
25
27
|
assert_equal client, object.client
|
26
|
-
assert_equal accessor, object.accessor
|
27
28
|
assert_equal attributes, object.attributes
|
28
29
|
end
|
29
30
|
|
@@ -138,7 +139,7 @@ describe 'MyJohnDeereApi::Request::Create::AssetLocation' do
|
|
138
139
|
it 'makes the request' do
|
139
140
|
VCR.use_cassette('post_asset_locations') { object.request }
|
140
141
|
|
141
|
-
|
142
|
+
assert_created(object.response)
|
142
143
|
end
|
143
144
|
end
|
144
145
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'support/helper'
|
2
2
|
|
3
3
|
describe 'MyJohnDeereApi::Request::Create::Asset' do
|
4
|
+
include JD::ResponseHelpers
|
5
|
+
|
4
6
|
def attributes_without(*keys)
|
5
7
|
keys = keys.to_a
|
6
8
|
attributes.reject{|k,v| keys.include?(k)}
|
@@ -22,7 +24,6 @@ describe 'MyJohnDeereApi::Request::Create::Asset' do
|
|
22
24
|
describe '#initialize(client, attributes)' do
|
23
25
|
it 'accepts a client and attributes' do
|
24
26
|
assert_equal client, object.client
|
25
|
-
assert_equal accessor, object.accessor
|
26
27
|
assert_equal attributes, object.attributes
|
27
28
|
end
|
28
29
|
end
|
@@ -121,7 +122,7 @@ describe 'MyJohnDeereApi::Request::Create::Asset' do
|
|
121
122
|
describe '#resource' do
|
122
123
|
it 'is built from the organization id' do
|
123
124
|
object = klass.new(client, attributes)
|
124
|
-
assert_equal "/organizations/#{organization_id}/assets", object.send(:resource)
|
125
|
+
assert_equal "/platform/organizations/#{organization_id}/assets", object.send(:resource)
|
125
126
|
end
|
126
127
|
end
|
127
128
|
|
@@ -159,7 +160,7 @@ describe 'MyJohnDeereApi::Request::Create::Asset' do
|
|
159
160
|
it 'makes the request' do
|
160
161
|
VCR.use_cassette('post_assets') { object.request }
|
161
162
|
|
162
|
-
|
163
|
+
assert_created object.response
|
163
164
|
end
|
164
165
|
end
|
165
166
|
|
@@ -170,7 +171,7 @@ describe 'MyJohnDeereApi::Request::Create::Asset' do
|
|
170
171
|
|
171
172
|
assert_kind_of JD::Model::Asset, result
|
172
173
|
|
173
|
-
expected_id = object.response['location'].split('/').last
|
174
|
+
expected_id = object.response.headers['location'].split('/').last
|
174
175
|
|
175
176
|
assert_equal expected_id, result.id
|
176
177
|
assert_equal attributes[:title], result.title
|
@@ -9,21 +9,7 @@ describe 'MyJohnDeereApi::Request::Create::Base' do
|
|
9
9
|
object = klass.new(client, attributes)
|
10
10
|
|
11
11
|
assert_equal client, object.client
|
12
|
-
assert_equal accessor, object.accessor
|
13
12
|
assert_equal attributes, object.attributes
|
14
13
|
end
|
15
14
|
end
|
16
|
-
|
17
|
-
describe '#headers' do
|
18
|
-
it 'sets the accept and content-type headers' do
|
19
|
-
object = klass.new(client, attributes)
|
20
|
-
headers = object.send(:headers)
|
21
|
-
|
22
|
-
expected = 'application/vnd.deere.axiom.v3+json'
|
23
|
-
|
24
|
-
assert_kind_of Hash, headers
|
25
|
-
assert_equal expected, headers['Accept']
|
26
|
-
assert_equal expected, headers['Content-Type']
|
27
|
-
end
|
28
|
-
end
|
29
15
|
end
|
@@ -10,7 +10,6 @@ describe 'MyJohnDeereApi::Request::Individual::Asset' do
|
|
10
10
|
describe '#initialize(client, asset_id)' do
|
11
11
|
it 'accepts a client' do
|
12
12
|
assert_equal client, object.client
|
13
|
-
assert_equal accessor, object.accessor
|
14
13
|
end
|
15
14
|
|
16
15
|
it 'accepts asset_id as id' do
|
@@ -19,8 +18,8 @@ describe 'MyJohnDeereApi::Request::Individual::Asset' do
|
|
19
18
|
end
|
20
19
|
|
21
20
|
describe '#resource' do
|
22
|
-
it 'returns /assets/<asset_id>' do
|
23
|
-
assert_equal "/assets/#{asset_id}", object.resource
|
21
|
+
it 'returns /platform/assets/<asset_id>' do
|
22
|
+
assert_equal "/platform/assets/#{asset_id}", object.resource
|
24
23
|
end
|
25
24
|
end
|
26
25
|
|
@@ -10,7 +10,6 @@ describe 'MyJohnDeereApi::Request::Individual::ContributionDefinition' do
|
|
10
10
|
describe '#initialize(client, contribution_definition_id)' do
|
11
11
|
it 'accepts a client' do
|
12
12
|
assert_equal client, object.client
|
13
|
-
assert_equal accessor, object.accessor
|
14
13
|
end
|
15
14
|
|
16
15
|
it 'accepts contribution_definition_id as id' do
|
@@ -19,8 +18,8 @@ describe 'MyJohnDeereApi::Request::Individual::ContributionDefinition' do
|
|
19
18
|
end
|
20
19
|
|
21
20
|
describe '#resource' do
|
22
|
-
it 'returns /contributionDefinitions/<definition_id>' do
|
23
|
-
assert_equal "/contributionDefinitions/#{contribution_definition_id}", object.resource
|
21
|
+
it 'returns /platform/contributionDefinitions/<definition_id>' do
|
22
|
+
assert_equal "/platform/contributionDefinitions/#{contribution_definition_id}", object.resource
|
24
23
|
end
|
25
24
|
end
|
26
25
|
|