spyke 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fe31d061e32e3c43bbbd1f2ab65af081fd82d967
4
- data.tar.gz: 388748ebaf5ab22e1ffae4ec9007559fc4ac127d
3
+ metadata.gz: 4e5a33fdcfc000148eb3e3433b01207a31b007db
4
+ data.tar.gz: 443a50064d6ed572b4783037a09b6ae2ceaee48e
5
5
  SHA512:
6
- metadata.gz: 31f2734a11911f1149701b338482ce5faa379e415d3a745bd9d50615557018be61e934c3939215289a92a4ef3e638634fa469796900b7fb61e5fd41c96d0e82c
7
- data.tar.gz: 2bf2903f8dab9d3ab41ce19b876ee4ca077bfa72b0af133b840a0d6b3d18d62912b774461f3ac63aafd7a33d5e7fb76aaff49c767ec9c614edb69360e8e7db2b
6
+ metadata.gz: 5219817c71603843bd3e0219f3a9b3fa32e23f96d88f1711de262cd766966ce874febc871a731628c10a36e5b107fb2b7d51a53d56b8af76231d9a1fe63f71b8
7
+ data.tar.gz: 5808dc0e274e18b6287ce0053ec351caba0c51b1292a395efb9b6ef449744af3886642d73d169dd3cb883fd5272da2ab063382bcd62bbb2be3fe25c7613c9ec5
@@ -20,6 +20,11 @@ module Spyke
20
20
  self
21
21
  end
22
22
 
23
+ # Overrides Enumerable find
24
+ def find(id)
25
+ scoping { klass.find(id) }
26
+ end
27
+
23
28
  def find_one
24
29
  @find_one ||= klass.new_from_result(fetch)
25
30
  end
@@ -1,3 +1,3 @@
1
1
  module Spyke
2
- VERSION = '1.1.1'
2
+ VERSION = '1.1.2'
3
3
  end
@@ -33,7 +33,7 @@ module Spyke
33
33
  assert_equal %w{ Fish }, recipe.groups.map(&:name)
34
34
  end
35
35
 
36
- def test_nested_embedded_associtations
36
+ def test_nested_embedded_associations
37
37
  json = { result: { groups: [{ ingredients: [{ id: 1, name: 'Fish' }] }, { ingredients: [] }] } }
38
38
  stub_request(:get, 'http://sushi.com/recipes/1').to_return_json(json)
39
39
 
@@ -42,7 +42,7 @@ module Spyke
42
42
  assert_equal %w{ Fish }, recipe.ingredients.map(&:name)
43
43
  end
44
44
 
45
- def test_singular_associtations
45
+ def test_singular_associations
46
46
  stub_request(:get, 'http://sushi.com/recipes/1').to_return_json(result: { image: { url: 'bob.jpg' } })
47
47
 
48
48
  recipe = Recipe.find(1)
@@ -59,6 +59,15 @@ module Spyke
59
59
  assert_requested endpoint
60
60
  end
61
61
 
62
+ def test_find_on_has_many_association
63
+ endpoint = stub_request(:get, 'http://sushi.com/recipes/1/groups/1').to_return_json(result: { id: 1 })
64
+
65
+ group = Recipe.new(id: 1).groups.find(1)
66
+
67
+ assert_requested endpoint
68
+ assert_equal 1, group.id
69
+ end
70
+
62
71
  def test_unloaded_has_one_association
63
72
  endpoint = stub_request(:get, 'http://sushi.com/recipes/1/image').to_return_json(result: { url: 'bob.jpg' })
64
73
 
@@ -12,6 +12,14 @@ module Spyke
12
12
  assert_equal 'meta', recipes.metadata
13
13
  end
14
14
 
15
+ def test_scope_with_find
16
+ endpoint = stub_request(:get, 'http://sushi.com/recipes/1?status=published').to_return_json(result: { id: 1 })
17
+
18
+ Recipe.where(status: 'published').find(1)
19
+
20
+ assert_requested endpoint
21
+ end
22
+
15
23
  def test_chainable_where
16
24
  endpoint = stub_request(:get, 'http://sushi.com/recipes?status=published&per_page=3')
17
25
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spyke
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Balvig
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-03 00:00:00.000000000 Z
11
+ date: 2014-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport