lhc 9.4.3 → 9.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lhc/request.rb +2 -2
- data/lib/lhc/version.rb +1 -1
- data/spec/request/url_patterns_spec.rb +29 -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: 35f64115a3a18dcad3d0494af2afe221aba124a22358f3be7b27dad63ccca55c
|
4
|
+
data.tar.gz: 14e25b16e6053a1db7db44dde741a1c48a715b0fc64e9865fe18cbd755baa976
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fa8c49a2b87857e7f44746166f60ad0ab572520a005fbbce14e5a7909c2f661bd8ab1f3f6becc55a1d54b9d89879c3221d9062edf8c5575de38505e857e1323
|
7
|
+
data.tar.gz: 46d331a87f5acfdd8bbea6b139cb6d9dacbbce0a3757d2f8be36299bba544b5a78e5f0753504e31da12a92627718e2b49b59aaf9962b67297a54308af467a011
|
data/lib/lhc/request.rb
CHANGED
@@ -109,8 +109,8 @@ class LHC::Request
|
|
109
109
|
def generate_url_from_template!
|
110
110
|
endpoint = LHC::Endpoint.new(options[:url])
|
111
111
|
params =
|
112
|
-
if format && options[:body]
|
113
|
-
options[:body].merge(options[:params] || {}).deep_symbolize_keys
|
112
|
+
if format && options[:body].present? && options[:body].respond_to?(:as_json) && options[:body].as_json.is_a?(Hash)
|
113
|
+
options[:body].as_json.merge(options[:params] || {}).deep_symbolize_keys
|
114
114
|
else
|
115
115
|
options[:params]
|
116
116
|
end
|
data/lib/lhc/version.rb
CHANGED
@@ -20,4 +20,33 @@ describe LHC::Request do
|
|
20
20
|
stub_request(:post, "http://datastore:8080/v2/places/123")
|
21
21
|
LHC.json.post('http://datastore:8080/v2/places/{id}', body: { id: 123 })
|
22
22
|
end
|
23
|
+
|
24
|
+
context 'custom data structures that respond to as_json (like LHS data or record)' do
|
25
|
+
before do
|
26
|
+
class CustomStructure
|
27
|
+
|
28
|
+
def initialize(data)
|
29
|
+
@data = data
|
30
|
+
end
|
31
|
+
|
32
|
+
def as_json
|
33
|
+
@data.as_json
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_json
|
37
|
+
as_json.to_json
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
let(:data) do
|
43
|
+
CustomStructure.new(id: '12345')
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'compiles url from body params when body object respond_to(:as_json)' do
|
47
|
+
stub_request(:post, "http://datastore/places/12345")
|
48
|
+
.to_return(status: 200)
|
49
|
+
LHC.post('http://datastore/places/{id}', body: data)
|
50
|
+
end
|
51
|
+
end
|
23
52
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lhc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 9.4.
|
4
|
+
version: 9.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- https://github.com/local-ch/lhc/contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|