spyke 1.8.7 → 1.8.8
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e04b56075f974a364cfaf6a44a25969ed1e8e730
|
4
|
+
data.tar.gz: 3c8ca7d4e89e05d38ddd0d8bfe9cc1ef7872c5c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3be8168169455f6458669224e6b488f13a7eccbfba2e08b632f047e3d1be9327b12d7e2c0b34f692d28e5106c647767672b45ea7cdc74760a85f70a775b6cd26
|
7
|
+
data.tar.gz: 554aabbd1b06e666b76d6334a85089d0d03f707256209e204ece5e4043ea10e5ac1277626601d191ad69e48e145dd47d61ce5214da88dcde065c29cbd27425b3
|
@@ -3,7 +3,7 @@ module Spyke
|
|
3
3
|
class BelongsTo < Association
|
4
4
|
def initialize(*args)
|
5
5
|
super
|
6
|
-
@options.reverse_merge!(uri: "/#{
|
6
|
+
@options.reverse_merge!(uri: "/#{@name.to_s.pluralize}/:id", foreign_key: "#{klass.model_name.param_key}_id")
|
7
7
|
@params[:id] = parent.try(foreign_key)
|
8
8
|
end
|
9
9
|
end
|
@@ -3,7 +3,7 @@ module Spyke
|
|
3
3
|
class HasMany < Association
|
4
4
|
def initialize(*args)
|
5
5
|
super
|
6
|
-
@options.reverse_merge!(uri: "/#{parent.class.model_name.plural}/:#{foreign_key}/#{
|
6
|
+
@options.reverse_merge!(uri: "/#{parent.class.model_name.plural}/:#{foreign_key}/#{@name}/(:id)")
|
7
7
|
@params[foreign_key] = parent.id
|
8
8
|
end
|
9
9
|
|
@@ -3,7 +3,7 @@ module Spyke
|
|
3
3
|
class HasOne < Association
|
4
4
|
def initialize(*args)
|
5
5
|
super
|
6
|
-
@options.reverse_merge!(uri: "/#{parent.class.model_name.plural}/:#{foreign_key}/#{
|
6
|
+
@options.reverse_merge!(uri: "/#{parent.class.model_name.plural}/:#{foreign_key}/#{@name}")
|
7
7
|
@params[foreign_key] = parent.id
|
8
8
|
end
|
9
9
|
end
|
data/lib/spyke/version.rb
CHANGED
data/test/associations_test.rb
CHANGED
@@ -236,6 +236,12 @@ module Spyke
|
|
236
236
|
assert_requested endpoint
|
237
237
|
end
|
238
238
|
|
239
|
+
def test_path_inferred_from_name
|
240
|
+
endpoint = stub_request(:get, 'http://sushi.com/recipes/1/gallery_images')
|
241
|
+
Recipe.new(id: 1).gallery_images.to_a
|
242
|
+
assert_requested endpoint
|
243
|
+
end
|
244
|
+
|
239
245
|
def test_create_association
|
240
246
|
endpoint = stub_request(:post, 'http://sushi.com/recipes/1/groups').with(body: { group: { title: 'Topping' } }).to_return_json(result: { title: 'Topping', id: 1, recipe_id: 1 })
|
241
247
|
|
data/test/support/fixtures.rb
CHANGED
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.8.
|
4
|
+
version: 1.8.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jens Balvig
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|