spyke 6.0.0 → 6.1.0

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
  SHA256:
3
- metadata.gz: 23653781200f18b330b2e78e4dd4adf51d928f1835b600be6a7c836f23d8ec15
4
- data.tar.gz: 69b1d6472dde425e63e267e21b1b2660e2407bc805a60456ee2b89f055e8760d
3
+ metadata.gz: '0503658448e2cd567bfa85ec96f1a339dbb7c59690bff9b3cda1c2a0d727bab7'
4
+ data.tar.gz: 4ecd65b52680c1dce5f30eddad68fa544a781ea5f30984c55804aa839d93fe91
5
5
  SHA512:
6
- metadata.gz: 1fc271dceb9578df58082af323786c241cdd4c23e0b78611b2839c64a50d30cdad780156c5afd79df55601265ca3468a4bdfe60b6c041f573d44133a0a39a8d6
7
- data.tar.gz: a52dd019cc4f8fdf21ab95708ed04f666411f0cf3d4f6c4c24d3702c1308fcc562c4eacc4ec2c354fada1d26ab8e6d495b1e0d6c113922542b67efcdee9d95fe
6
+ metadata.gz: b143845d229f8b712b2d6f1d5d14ba36939a2bab6b90e835f35e5a499a1b06ee93087ecce81f46b9ebc9e7a4c92b9988d53c1ff2798f378e4e76fd9b12ceeb88
7
+ data.tar.gz: 22b3baeeac2cbaa4c0667c805eb4a33f011e6d0c333777b89766ba857e19f322374e215412d42b92c993b6f64ca80b2fb9cd89d14efaa42279d50ce3bdd2d68b
data/lib/spyke/http.rb CHANGED
@@ -46,7 +46,8 @@ module Spyke
46
46
  def send_request(method, path, params)
47
47
  connection.send(method) do |request|
48
48
  if method == :get
49
- request.url path.to_s, params
49
+ path, params = merge_query_params(path, params)
50
+ request.url path, params
50
51
  else
51
52
  request.url path.to_s
52
53
  request.body = params
@@ -56,6 +57,13 @@ module Spyke
56
57
  raise ConnectionError
57
58
  end
58
59
 
60
+ def merge_query_params(path, params)
61
+ parsed_uri = Addressable::URI.parse(path.to_s)
62
+ path = parsed_uri.path
63
+ params = params.merge(parsed_uri.query_values || {})
64
+ [path, params]
65
+ end
66
+
59
67
  def scoped_request(method)
60
68
  uri = new.uri
61
69
  params = current_scope.params.except(*uri.variables)
data/lib/spyke/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Spyke
2
- VERSION = '6.0.0'
2
+ VERSION = '6.1.0'
3
3
  end
@@ -241,6 +241,15 @@ module Spyke
241
241
  assert_requested endpoint
242
242
  end
243
243
 
244
+
245
+ def test_using_where_with_custom_uri_including_query_params
246
+ endpoint = stub_request(:get, 'http://sushi.com/featured_ingredients?filter[group_id]=1&filter[status]=published')
247
+
248
+ Group.new(id: 1).featured_ingredients.where(filter: { status: 'published' }).to_a
249
+
250
+ assert_requested endpoint
251
+ end
252
+
244
253
  def test_path_inferred_from_name
245
254
  endpoint = stub_request(:get, 'http://sushi.com/recipes/1/gallery_images')
246
255
  Recipe.new(id: 1).gallery_images.to_a
data/test/path_test.rb CHANGED
@@ -21,13 +21,13 @@ module Spyke
21
21
  end
22
22
 
23
23
  def test_required_variables
24
- assert_raises Spyke::InvalidPathError, 'Missing required variables: user_id in /users/:user_id/recipes/(:id)' do
24
+ assert_raises InvalidPathError, 'Missing required variables: user_id in /users/:user_id/recipes/(:id)' do
25
25
  Path.new('/users/:user_id/recipes/(:id)', id: 2).to_s
26
26
  end
27
27
  end
28
28
 
29
29
  def test_mix_of_required_and_unrequired_variables
30
- assert_raises Spyke::InvalidPathError, 'Missing required variables: part2, part4' do
30
+ assert_raises InvalidPathError, 'Missing required variables: part2, part4' do
31
31
  Path.new('/1/profiles(/:part1)/:part2(/:part3)/:part4.xml').to_s
32
32
  end
33
33
  end
@@ -79,6 +79,7 @@ end
79
79
 
80
80
  class Group < Spyke::Base
81
81
  has_many :ingredients, uri: nil
82
+ has_many :featured_ingredients, uri: 'featured_ingredients?filter[group_id]=:group_id', class_name: "Ingredient"
82
83
  accepts_nested_attributes_for :ingredients
83
84
 
84
85
  def self.build_default
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: 6.0.0
4
+ version: 6.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Balvig
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-12 00:00:00.000000000 Z
11
+ date: 2021-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport