lhc 9.4.2 → 9.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be1b987dd272ded2704dca72606d5a96ee394ec8e901cb5c72c164bfa4c116fe
4
- data.tar.gz: 881da124498450bdd8e9b6d4c4ba8244f84f8dbe3918381af320be267069152e
3
+ metadata.gz: a020f77f047005cae5e2783018a8e845a619ae594d7c2567e2eb20cb6d71f965
4
+ data.tar.gz: 105f2df6c51e19750bf4c180382be1c4f2fe9865c7a82ff5708ead4362212858
5
5
  SHA512:
6
- metadata.gz: 56a29c2ee5e170542d8ddba9bc4e212b4c29bd1a98b2d88b3484b31caadc8bfc034179d653fa289ff9de3864345ce399e65628f210be92d0f8a2f9bef772b991
7
- data.tar.gz: 5b0cf0dc644a3f139b64ef50459be033ce9b0cd317782245ebbfc72ec0de57a4714596437819d197e282db85d4ccdb76fe8f0f23d1ead1098479207719649868
6
+ metadata.gz: f288a674f51be5c50be0b013b637af67c81138453af9f5d043b075898ce76ce2d4b1275a77e180bb53849eacc1c96b990f1c9ca8eb6e77c19ee79a35c15e3fe4
7
+ data.tar.gz: 2f9a0c9e3a7563759d069d861fc96337e27733c653c066a512f3d28e7a263decab10c707f20ba850230402a22e83412ccdfb447f0741985d02b0f8a1359127a5
data/README.md CHANGED
@@ -400,7 +400,7 @@ Take care that you only use `LHC.configure` once, because it is actually resetin
400
400
  ```ruby
401
401
 
402
402
  LHC.configure do |c|
403
- c.placeholder :datastore, 'http://datastore/v2'
403
+ c.placeholder :datastore, 'http://datastore'
404
404
  c.endpoint :feedbacks, '{+datastore}/feedbacks', params: { has_reviews: true }
405
405
  c.interceptors = [CachingInterceptor, MonitorInterceptor, TrackingIdInterceptor]
406
406
  end
@@ -433,7 +433,7 @@ You can configure global placeholders, that are used when generating urls from u
433
433
 
434
434
  ```ruby
435
435
  LHC.configure do |c|
436
- c.placeholder(:datastore, 'http://datastore/v2')
436
+ c.placeholder(:datastore, 'http://datastore')
437
437
  c.endpoint(:feedbacks, '{+datastore}/feedbacks', { params: { has_reviews: true } })
438
438
  end
439
439
 
@@ -19,7 +19,11 @@ module LHC::Formats
19
19
  end
20
20
 
21
21
  def to_body(input)
22
- input.to_json
22
+ if input.is_a?(String)
23
+ input
24
+ else
25
+ input.to_json
26
+ end
23
27
  end
24
28
 
25
29
  def to_s
@@ -109,7 +109,7 @@ 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]&.length
112
+ if format && options[:body]&.length && options[:body].is_a?(Hash)
113
113
  options[:body].merge(options[:params] || {}).deep_symbolize_keys
114
114
  else
115
115
  options[:params]
@@ -1,3 +1,3 @@
1
1
  module LHC
2
- VERSION ||= '9.4.2'
2
+ VERSION ||= '9.4.3'
3
3
  end
@@ -0,0 +1,37 @@
1
+ require 'rails_helper'
2
+
3
+ describe LHC::Request do
4
+ context 'encode body' do
5
+ let(:encoded_data) { data.to_json }
6
+
7
+ before do
8
+ stub_request(:post, "http://datastore/q")
9
+ .with(body: encoded_data)
10
+ .to_return(status: 200)
11
+ end
12
+
13
+ context 'hash' do
14
+ let(:data) { { name: 'Steve' } }
15
+
16
+ it 'encodes the request body to the given format' do
17
+ LHC.post('http://datastore/q', body: data)
18
+ end
19
+
20
+ it 'does not encode the request body if it is already a string' do
21
+ LHC.post('http://datastore/q', body: encoded_data)
22
+ end
23
+ end
24
+
25
+ context 'array' do
26
+ let(:data) { [{ name: 'Steve' }] }
27
+
28
+ it 'encodes the request body to the given format' do
29
+ LHC.post('http://datastore/q', body: data)
30
+ end
31
+
32
+ it 'does not encode the request body if it is already a string' do
33
+ LHC.post('http://datastore/q', body: encoded_data)
34
+ end
35
+ end
36
+ end
37
+ 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.2
4
+ version: 9.4.3
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-08-20 00:00:00.000000000 Z
11
+ date: 2018-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -314,6 +314,7 @@ files:
314
314
  - spec/interceptors/rollbar/main_spec.rb
315
315
  - spec/interceptors/zipkin/distributed_tracing_spec.rb
316
316
  - spec/rails_helper.rb
317
+ - spec/request/body_spec.rb
317
318
  - spec/request/encoding_spec.rb
318
319
  - spec/request/error_handling_spec.rb
319
320
  - spec/request/headers_spec.rb
@@ -362,7 +363,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
362
363
  requirements:
363
364
  - Ruby >= 2.0.0
364
365
  rubyforge_project:
365
- rubygems_version: 2.7.6
366
+ rubygems_version: 2.7.7
366
367
  signing_key:
367
368
  specification_version: 4
368
369
  summary: Advanced HTTP Client for Ruby, fueled with interceptors
@@ -454,6 +455,7 @@ test_files:
454
455
  - spec/interceptors/rollbar/main_spec.rb
455
456
  - spec/interceptors/zipkin/distributed_tracing_spec.rb
456
457
  - spec/rails_helper.rb
458
+ - spec/request/body_spec.rb
457
459
  - spec/request/encoding_spec.rb
458
460
  - spec/request/error_handling_spec.rb
459
461
  - spec/request/headers_spec.rb