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 +4 -4
- data/lib/spyke/http.rb +9 -1
- data/lib/spyke/version.rb +1 -1
- data/test/associations_test.rb +9 -0
- data/test/path_test.rb +2 -2
- data/test/support/fixtures.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0503658448e2cd567bfa85ec96f1a339dbb7c59690bff9b3cda1c2a0d727bab7'
|
4
|
+
data.tar.gz: 4ecd65b52680c1dce5f30eddad68fa544a781ea5f30984c55804aa839d93fe91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
data/test/associations_test.rb
CHANGED
@@ -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
|
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
|
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
|
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: 6.
|
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
|
11
|
+
date: 2021-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|