my_john_deere_api 2.3.0 → 2.3.1
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 +4 -4
- data/lib/my_john_deere_api/helpers/validate_contribution_definition.rb +18 -0
- data/lib/my_john_deere_api/helpers.rb +1 -0
- data/lib/my_john_deere_api/request/create/asset.rb +1 -0
- data/lib/my_john_deere_api/request/create/base.rb +0 -11
- data/lib/my_john_deere_api/request/update/asset.rb +1 -0
- data/lib/my_john_deere_api/request/update/base.rb +0 -11
- data/lib/my_john_deere_api/version.rb +1 -1
- data/test/lib/my_john_deere_api/helpers/validate_contribution_definition_test.rb +74 -0
- data/test/lib/my_john_deere_api/helpers_test.rb +4 -0
- data/test/lib/my_john_deere_api/request/create/base_test.rb +0 -16
- data/test/lib/my_john_deere_api/request/update/base_test.rb +0 -16
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b7e56857d5db19f8704d06453efd6c258a59301fbfd046fa9fc6f97f7ae0ae6
|
4
|
+
data.tar.gz: a6c869c73bc36401c52334c207964b34b4753cedef3dcd227c6f7f3afa81a53b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8efc6cc4fc3e1609baff17d01c41c58d022dc1a5c144b012f2f4a813e059bdee5b4c6b648ceab217586176179e5e51a7e568ff52e250a7e1ed089f247131c4a
|
7
|
+
data.tar.gz: 82ad3bebb98fbd194cf6f5e2772203548c52be2f203e1cd6564562cc2d8c24045f45be8f9616243113f84537561f28b08798c556a17b8b32608e4e01b5fd913f
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'uri'
|
2
|
+
|
3
|
+
module MyJohnDeereApi
|
4
|
+
module Helpers::ValidateContributionDefinition
|
5
|
+
private
|
6
|
+
|
7
|
+
##
|
8
|
+
# Raise an error if contribution_definition_id is missing
|
9
|
+
|
10
|
+
def validate_contribution_definition
|
11
|
+
if client.contribution_definition_id.nil?
|
12
|
+
raise MissingContributionDefinitionIdError
|
13
|
+
end
|
14
|
+
|
15
|
+
true
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -2,4 +2,5 @@ module MyJohnDeereApi::Helpers
|
|
2
2
|
autoload :UriHelpers, 'my_john_deere_api/helpers/uri_helpers'
|
3
3
|
autoload :CaseConversion, 'my_john_deere_api/helpers/case_conversion'
|
4
4
|
autoload :EnvironmentHelper, 'my_john_deere_api/helpers/environment_helper'
|
5
|
+
autoload :ValidateContributionDefinition, 'my_john_deere_api/helpers/validate_contribution_definition'
|
5
6
|
end
|
@@ -54,17 +54,6 @@ module MyJohnDeereApi
|
|
54
54
|
def process_attributes
|
55
55
|
end
|
56
56
|
|
57
|
-
##
|
58
|
-
# Raise an error if contribution_definition_id is missing
|
59
|
-
|
60
|
-
def validate_contribution_definition
|
61
|
-
unless client.contribution_definition_id
|
62
|
-
raise MissingContributionDefinitionIdError
|
63
|
-
end
|
64
|
-
|
65
|
-
true
|
66
|
-
end
|
67
|
-
|
68
57
|
##
|
69
58
|
# Headers for POST request
|
70
59
|
|
@@ -54,17 +54,6 @@ module MyJohnDeereApi
|
|
54
54
|
def process_attributes
|
55
55
|
end
|
56
56
|
|
57
|
-
##
|
58
|
-
# Raise an error if contribution_definition_id is missing
|
59
|
-
|
60
|
-
def validate_contribution_definition
|
61
|
-
unless client.contribution_definition_id
|
62
|
-
raise MissingContributionDefinitionIdError
|
63
|
-
end
|
64
|
-
|
65
|
-
true
|
66
|
-
end
|
67
|
-
|
68
57
|
##
|
69
58
|
# Headers for PUT request
|
70
59
|
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'support/helper'
|
2
|
+
|
3
|
+
class ValidateContributionDefinitionHelperSample
|
4
|
+
include JD::Helpers::ValidateContributionDefinition
|
5
|
+
|
6
|
+
attr_reader :client
|
7
|
+
|
8
|
+
def initialize(client)
|
9
|
+
@client = client
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'Helpers::ValidateContributionDefinition' do
|
14
|
+
let(:object) { ValidateContributionDefinitionHelperSample.new(client) }
|
15
|
+
|
16
|
+
describe '#validate_contribution_definition' do
|
17
|
+
it 'returns true when contribution_definition_id is present' do
|
18
|
+
assert object.send(:validate_contribution_definition)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'raises an error when contribution_definition_id is missing' do
|
22
|
+
client.contribution_definition_id = nil
|
23
|
+
|
24
|
+
assert_raises(JD::MissingContributionDefinitionIdError) do
|
25
|
+
object.send(:validate_contribution_definition)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# describe '#uri_path' do
|
31
|
+
# it 'extracts the path from the uri' do
|
32
|
+
# path = object.send(:uri_path, 'https://example.com/turtles')
|
33
|
+
# assert_equal '/turtles', path
|
34
|
+
# end
|
35
|
+
#
|
36
|
+
# it 'removes leading /platform from the path' do
|
37
|
+
# path = object.send(:uri_path, 'https://example.com/platform/turtles')
|
38
|
+
# assert_equal '/turtles', path
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
# it 'preserves /platform in any other part of the path' do
|
42
|
+
# path = object.send(:uri_path, 'https://example.com/platform/turtles/platform')
|
43
|
+
# assert_equal '/turtles/platform', path
|
44
|
+
# end
|
45
|
+
#
|
46
|
+
# it 'is a private method' do
|
47
|
+
# exception = assert_raises(NoMethodError) { object.uri_path('https://example.com/turtles')}
|
48
|
+
# assert_includes exception.message, 'private method'
|
49
|
+
# end
|
50
|
+
# end
|
51
|
+
#
|
52
|
+
# describe '#id_from_uri(uri, label)' do
|
53
|
+
# it 'extracts the id immediately following a given label' do
|
54
|
+
# uri = 'https://example.com/cows/123/pigs/456/turtles/789/birds/012'
|
55
|
+
# assert_equal '789', object.send(:id_from_uri, uri, 'turtles')
|
56
|
+
# end
|
57
|
+
#
|
58
|
+
# it 'accepts a symbol for the label' do
|
59
|
+
# uri = 'https://example.com/cows/123/pigs/456/turtles/789/birds/012'
|
60
|
+
# assert_equal '789', object.send(:id_from_uri, uri, :turtles)
|
61
|
+
# end
|
62
|
+
#
|
63
|
+
# it 'is a private method' do
|
64
|
+
# uri = 'https://example.com/cows/123/pigs/456/turtles/789/birds/012'
|
65
|
+
#
|
66
|
+
# exception = assert_raises(NoMethodError) { object.id_from_uri(uri, 'turtles') }
|
67
|
+
# assert_includes exception.message, 'private method'
|
68
|
+
# end
|
69
|
+
# end
|
70
|
+
#
|
71
|
+
# it "preserves the public nature of the including class's other methods" do
|
72
|
+
# assert_equal 'test', object.test
|
73
|
+
# end
|
74
|
+
end
|
@@ -13,5 +13,9 @@ describe 'MyJohnDeereApi::Helpers' do
|
|
13
13
|
it 'loads Helpers::EnvironmentHelper' do
|
14
14
|
assert JD::Helpers::EnvironmentHelper
|
15
15
|
end
|
16
|
+
|
17
|
+
it 'loads Helpers::ValidateContributionDefinition' do
|
18
|
+
assert JD::Helpers::ValidateContributionDefinition
|
19
|
+
end
|
16
20
|
end
|
17
21
|
end
|
@@ -26,20 +26,4 @@ describe 'MyJohnDeereApi::Request::Create::Base' do
|
|
26
26
|
assert_equal expected, headers['Content-Type']
|
27
27
|
end
|
28
28
|
end
|
29
|
-
|
30
|
-
describe '#validate_contribution_definition' do
|
31
|
-
it 'does nothing when contribution_definition_id is present' do
|
32
|
-
object = klass.new(client, attributes)
|
33
|
-
assert object.send(:validate_contribution_definition)
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'raises an error when contribution_definition_id is missing' do
|
37
|
-
client.contribution_definition_id = nil
|
38
|
-
object = klass.new(client, attributes)
|
39
|
-
|
40
|
-
assert_raises(JD::MissingContributionDefinitionIdError) do
|
41
|
-
object.send(:validate_contribution_definition)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
29
|
end
|
@@ -57,20 +57,4 @@ describe 'MyJohnDeereApi::Request::Update::Base' do
|
|
57
57
|
assert_equal expected, headers['Content-Type']
|
58
58
|
end
|
59
59
|
end
|
60
|
-
|
61
|
-
describe '#validate_contribution_definition' do
|
62
|
-
it 'does nothing when contribution_definition_id is present' do
|
63
|
-
object = klass.new(client, item, attributes)
|
64
|
-
assert object.send(:validate_contribution_definition)
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'raises an error when contribution_definition_id is missing' do
|
68
|
-
client.contribution_definition_id = nil
|
69
|
-
object = klass.new(client, item, attributes)
|
70
|
-
|
71
|
-
assert_raises(JD::MissingContributionDefinitionIdError) do
|
72
|
-
object.send(:validate_contribution_definition)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
60
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: my_john_deere_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jaime Bellmyer
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- lib/my_john_deere_api/helpers/case_conversion.rb
|
117
117
|
- lib/my_john_deere_api/helpers/environment_helper.rb
|
118
118
|
- lib/my_john_deere_api/helpers/uri_helpers.rb
|
119
|
+
- lib/my_john_deere_api/helpers/validate_contribution_definition.rb
|
119
120
|
- lib/my_john_deere_api/model.rb
|
120
121
|
- lib/my_john_deere_api/model/asset.rb
|
121
122
|
- lib/my_john_deere_api/model/asset_location.rb
|
@@ -166,6 +167,7 @@ files:
|
|
166
167
|
- test/lib/my_john_deere_api/helpers/case_conversion_test.rb
|
167
168
|
- test/lib/my_john_deere_api/helpers/environment_helper_test.rb
|
168
169
|
- test/lib/my_john_deere_api/helpers/uri_helpers_test.rb
|
170
|
+
- test/lib/my_john_deere_api/helpers/validate_contribution_definition_test.rb
|
169
171
|
- test/lib/my_john_deere_api/helpers_test.rb
|
170
172
|
- test/lib/my_john_deere_api/model/asset_location_test.rb
|
171
173
|
- test/lib/my_john_deere_api/model/asset_test.rb
|