lhc 10.0.1 → 10.0.2
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: fcff9d45e512c5c1a8c76aaffb710eb73d5a5b03909e167e5a584fc4614a6d19
|
4
|
+
data.tar.gz: 366dd2f2b123018ca3d06d21d2e3eafd75923a292f363a54e1c8163f78753286
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f57d6a94e86a60ec2866aefdf15f472353e270e0a8df7f88bbbded053f2d84dd59e7e3ff9027b9f629aa7a355e905a407dc41c7727996c53b35c6e76ebc09dc
|
7
|
+
data.tar.gz: d94e275d67dad755be1a0ce290eca7ff7a1defeaadf30ea202d6659eca9a14d23e14fc220b8992d4087278e806f851b36b0be28aa7b71873b6266f4dde6658c3
|
data/lib/lhc/request.rb
CHANGED
@@ -111,8 +111,8 @@ class LHC::Request
|
|
111
111
|
def generate_url_from_template!
|
112
112
|
endpoint = LHC::Endpoint.new(options[:url])
|
113
113
|
params =
|
114
|
-
if format && options[:body]
|
115
|
-
options[:body].merge(options[:params] || {}).deep_symbolize_keys
|
114
|
+
if format && options[:body].present? && options[:body].respond_to?(:as_json) && options[:body].as_json.is_a?(Hash)
|
115
|
+
options[:body].as_json.merge(options[:params] || {}).deep_symbolize_keys
|
116
116
|
else
|
117
117
|
options[:params]
|
118
118
|
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: 10.0.
|
4
|
+
version: 10.0.2
|
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
|