spark_api 1.4.2 → 1.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/VERSION +1 -1
- data/lib/spark_api/models/defaultable.rb +8 -4
- data/spec/unit/spark_api/models/defaultable_spec.rb +21 -12
- data/spec/unit/spark_api/models/finders_spec.rb +1 -0
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZmUwNzIwNTgwOWUxN2MzMGZhNmZmNzM1MWQwODJmNTUwOTRlMWIyNw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YWQyMWM3Y2Q5ODFlYzIzMTdlZjk1NDQwMDczNmNiMWQ2NTIwZDdlZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OGI2N2M2YTY2Mzg0MGVmYTlkZGFiOGI4YjVmNDFhYTIxYjYxODA4ZjQ5ZDEz
|
10
|
+
MTc2Yjk3NWZjNzU1MDVjZTAyYmYyYmViZTE5ODBkN2Y5YjZiOGMwOWJiZTYy
|
11
|
+
NGMxODEyOTJiN2YyNDRiYTM4MzkyZWZhMWM2MmNkYTQ5MzhmMjc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDBjOTcwMWU4MmFiOGRkZmE0YTVjZmYwZTlhMjQ4NmEwMjJiZGQ2ZGFmNDBm
|
14
|
+
M2ExM2I5MGNkNmRiZjZhN2MzYWIwNTc0MzdlYTY4OWE1ZjdjMTMzNmIzYzgw
|
15
|
+
YzgxZWRlNTliNDM4NGM0Y2I3NWJmYjQ3YTUxZGZhYWI1NWY4MjQ=
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.4.
|
1
|
+
1.4.4
|
@@ -19,15 +19,19 @@ module SparkApi
|
|
19
19
|
module ClassMethods
|
20
20
|
|
21
21
|
def default(options = {})
|
22
|
-
|
22
|
+
response = connection.get("/#{element_name}/default", options).first
|
23
|
+
unless response.nil?
|
24
|
+
response["Id"] = DEFAULT_ID if response["Id"].nil?
|
25
|
+
new(response)
|
26
|
+
end
|
23
27
|
end
|
24
28
|
|
25
29
|
def find(*arguments)
|
26
|
-
result = original_find(*arguments)
|
27
30
|
if arguments.first == DEFAULT_ID
|
28
|
-
|
31
|
+
default
|
32
|
+
else
|
33
|
+
original_find(*arguments)
|
29
34
|
end
|
30
|
-
result
|
31
35
|
end
|
32
36
|
|
33
37
|
end
|
@@ -14,24 +14,33 @@ describe Defaultable do
|
|
14
14
|
|
15
15
|
describe 'default' do
|
16
16
|
|
17
|
-
it '
|
18
|
-
|
19
|
-
TestClass.default
|
17
|
+
it 'returns an instance of the class' do
|
18
|
+
allow(TestClass).to receive(:connection).and_return(double(get: [{"Name" => 'foo'}]))
|
19
|
+
expect(TestClass.default).to be_a TestClass
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns nil when there are no results' do
|
23
|
+
allow(TestClass).to receive(:connection).and_return(double(get: []))
|
24
|
+
expect(TestClass.default).to be nil
|
25
|
+
end
|
26
|
+
|
27
|
+
it "assigns the default id to the instance if it doesn't have an id" do
|
28
|
+
allow(TestClass).to receive(:connection).and_return(double(get: [{"Name" => 'foo'}]))
|
29
|
+
expect(TestClass.default.Id).to eq TestClass::DEFAULT_ID
|
30
|
+
end
|
31
|
+
|
32
|
+
it "doesn't override the id if one is present" do
|
33
|
+
allow(TestClass).to receive(:connection).and_return(double(get: [{"Id" => '5', "Name" => 'foo'}]))
|
34
|
+
expect(TestClass.default.Id).to eq '5'
|
20
35
|
end
|
21
36
|
|
22
37
|
end
|
23
38
|
|
24
39
|
describe 'find' do
|
25
40
|
|
26
|
-
it "
|
27
|
-
|
28
|
-
|
29
|
-
expect(default.Id).to eq 'default'
|
30
|
-
end
|
31
|
-
|
32
|
-
it "doesn't override the id if one is present" do
|
33
|
-
allow(TestClass).to receive(:connection).and_return(double(get: [{Id: '5', Name: 'foo'}]))
|
34
|
-
expect(TestClass.find(TestClass::DEFAULT_ID).Id).to eq '5'
|
41
|
+
it "calls 'default' when given the default id" do
|
42
|
+
expect(TestClass).to receive(:default)
|
43
|
+
TestClass.find(TestClass::DEFAULT_ID)
|
35
44
|
end
|
36
45
|
|
37
46
|
it "calls Finders.find when given a normal id" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spark_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Hornseth
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-06-
|
12
|
+
date: 2016-06-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -233,6 +233,34 @@ dependencies:
|
|
233
233
|
- - ! '>='
|
234
234
|
- !ruby/object:Gem::Version
|
235
235
|
version: '0'
|
236
|
+
- !ruby/object:Gem::Dependency
|
237
|
+
name: listen
|
238
|
+
requirement: !ruby/object:Gem::Requirement
|
239
|
+
requirements:
|
240
|
+
- - ~>
|
241
|
+
- !ruby/object:Gem::Version
|
242
|
+
version: 3.0.8
|
243
|
+
type: :development
|
244
|
+
prerelease: false
|
245
|
+
version_requirements: !ruby/object:Gem::Requirement
|
246
|
+
requirements:
|
247
|
+
- - ~>
|
248
|
+
- !ruby/object:Gem::Version
|
249
|
+
version: 3.0.8
|
250
|
+
- !ruby/object:Gem::Dependency
|
251
|
+
name: guard-rspec
|
252
|
+
requirement: !ruby/object:Gem::Requirement
|
253
|
+
requirements:
|
254
|
+
- - ! '>='
|
255
|
+
- !ruby/object:Gem::Version
|
256
|
+
version: '0'
|
257
|
+
type: :development
|
258
|
+
prerelease: false
|
259
|
+
version_requirements: !ruby/object:Gem::Requirement
|
260
|
+
requirements:
|
261
|
+
- - ! '>='
|
262
|
+
- !ruby/object:Gem::Version
|
263
|
+
version: '0'
|
236
264
|
description: The spark_api gem handles most of the boilerplate for communicating with
|
237
265
|
the Spark API rest services, including authentication and request parsing.
|
238
266
|
email: api-support@sparkapi.com
|