spyke 1.8.7 → 1.8.8

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: 86fba5601363bb57856a5cd3eb2dce1d37d8514e
4
- data.tar.gz: 0fb9a9ae25540cc72fb6aac4513ed3d601e6412e
3
+ metadata.gz: e04b56075f974a364cfaf6a44a25969ed1e8e730
4
+ data.tar.gz: 3c8ca7d4e89e05d38ddd0d8bfe9cc1ef7872c5c2
5
5
  SHA512:
6
- metadata.gz: 70ae11278bc7c9e36fdbfc91a0884f3f0a2fbab1a35843df846007c0bb72027af981ab88848716976d528ff38adacee3c392c23c936add6ccabb325613eb5ee8
7
- data.tar.gz: 7f6dae12dd72823ef85e26329bd612656b3b2cbcf306a4cef14ce6b6964f5ed27ae60d1623333d4b8fc1d368d95cf67af283a1b362cbe06939bc29ec3a337aab
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: "/#{klass.model_name.plural}/:id", foreign_key: "#{klass.model_name.param_key}_id")
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}/#{klass.model_name.plural}/(:id)")
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}/#{klass.model_name.singular}")
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
@@ -1,3 +1,3 @@
1
1
  module Spyke
2
- VERSION = '1.8.7'
2
+ VERSION = '1.8.8'
3
3
  end
@@ -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
 
@@ -1,5 +1,6 @@
1
1
  class Recipe < Spyke::Base
2
2
  has_many :groups
3
+ has_many :gallery_images, class_name: 'Image'
3
4
  has_one :image
4
5
  has_one :background_image, class_name: 'Image', uri: nil
5
6
  has_one :alternate, class_name: 'Recipe', uri: '/recipes/:recipe_id/alternates/recipe'
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.7
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-22 00:00:00.000000000 Z
11
+ date: 2015-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport