myjohndeere 0.1.0 → 0.1.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/Gemfile.lock +1 -1
- data/lib/myjohndeere/field.rb +8 -1
- data/lib/myjohndeere/version.rb +1 -1
- data/test/test_field.rb +7 -0
- data/test/test_rest_methods.rb +4 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88190ee84652334c16e9feabec2d7b247fab5d50
|
4
|
+
data.tar.gz: 74175a45f890e7676e087291de5648b5ee829c6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c8818275027188a03e60fce2703553d8533ff85455ee25fe033feb84dda1c682f62e539531bbb2898d81588876efaa83a1d7bb01b74e08b9177b0c37947f877
|
7
|
+
data.tar.gz: 29f2ff820b98ab782ebccda2ccf6a7a76559d18bc6dc26bc8aa62f2284df847a5276f9e98590d8b240fea979a7c9ab5514bd6f4b9b873e372d9da3ccf6b12f4e
|
data/Gemfile.lock
CHANGED
data/lib/myjohndeere/field.rb
CHANGED
@@ -6,6 +6,7 @@ module MyJohnDeere
|
|
6
6
|
attributes_to_pull_from_json(:id, :name, :boundaries)
|
7
7
|
|
8
8
|
def initialize(json_object, access_token = nil)
|
9
|
+
@boundary = nil
|
9
10
|
super(json_object, access_token)
|
10
11
|
boundaries = json_object["boundaries"]
|
11
12
|
if boundaries && boundaries.length > 0 then
|
@@ -14,8 +15,14 @@ module MyJohnDeere
|
|
14
15
|
end
|
15
16
|
end
|
16
17
|
|
18
|
+
# Will return whether or not the boundary has been set,
|
19
|
+
# useful if you're expecting embedded boundaries
|
20
|
+
def boundary_unset?
|
21
|
+
return @boundary.nil?
|
22
|
+
end
|
23
|
+
|
17
24
|
def boundary
|
18
|
-
if
|
25
|
+
if self.boundary_unset? then
|
19
26
|
@boundary = Boundary.retrieve(self.access_token, field_id: self.id, organization_id: self.organization_id)
|
20
27
|
end
|
21
28
|
return @boundary
|
data/lib/myjohndeere/version.rb
CHANGED
data/test/test_field.rb
CHANGED
@@ -35,6 +35,13 @@ class TestField < Minitest::Test
|
|
35
35
|
assert_equal field.id, field.boundary.field_id
|
36
36
|
end
|
37
37
|
|
38
|
+
def test_boundary_unset
|
39
|
+
field = MyJohnDeere::Field.new({})
|
40
|
+
assert field.boundary_unset?
|
41
|
+
field.boundary = MyJohnDeere::Boundary.new({}, nil, 1)
|
42
|
+
assert !field.boundary_unset?
|
43
|
+
end
|
44
|
+
|
38
45
|
def test_list()
|
39
46
|
stub_request(:get, /organizations\/#{ORGANIZATION_FIXTURE["id"]}\/fields/).
|
40
47
|
to_return(status: 200, body: FIXTURE_FOR_LIST.to_json)
|
data/test/test_rest_methods.rb
CHANGED
@@ -63,11 +63,12 @@ class TestRestMethods < Minitest::Test
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def test_list_with_body
|
66
|
+
embed = {embed: "boundaries"}
|
66
67
|
stub_request(:get, /organizations/).
|
67
|
-
with(query:
|
68
|
+
with(query: embed,
|
68
69
|
headers: {MyJohnDeere::ETAG_HEADER_KEY=>""}).
|
69
70
|
to_return(status: 200, body: LIST_FIXTURE.to_json())
|
70
|
-
organizations = MyJohnDeere::Organization.list(default_access_token, count: 1, etag: "", body:
|
71
|
-
assert_equal(
|
71
|
+
organizations = MyJohnDeere::Organization.list(default_access_token, count: 1, etag: "", body: embed)
|
72
|
+
assert_equal(embed, organizations.options[:body])
|
72
73
|
end
|
73
74
|
end
|