lhs 19.4.0 → 19.4.1

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: eec02ca16e6732bb24ad68d18099937f48734dd000326fdfa07cd0365d3a0622
4
- data.tar.gz: 2e327627fdd24ae4588499376847512ff76d514f90666cbb9115bdcecae0403a
3
+ metadata.gz: 0a07eb02cb34aed5f562ed302246c31eacf746e786ffaf74d61420897662c5f3
4
+ data.tar.gz: 2d74239dda28e2d769a43d238c77b1594285283c3b676265f76643ce17649965
5
5
  SHA512:
6
- metadata.gz: b31fd1517f82df7b7d789888c2f878a9a9ce2f6ac6686b2193210f9a3c5d156f705852bac48974ae495dca7b6da374cec44dd3f0188cdea26891237c459465ea
7
- data.tar.gz: cf095950ddf9e8e00369f73051b8350dc86e5d3922679d50121983f9414bd343eae85d3e1d44e5a768daa2ba4b2eb24bdbe33737230ecdd5d63ec9cf6b3cf52d
6
+ metadata.gz: 8dabe6d68096aaba06f5c397aafd9b67d48c73209b42604b8c3579d5000c3a380bb7d58377d2bae373f45dd8d3d3fb8d834293b39e233e5259f354c50d956435
7
+ data.tar.gz: 3389c1ddcbc753e23d4d73b4d93ab28da0d837df602b096b274041c671db1bd2252b2374439268e11c5b6e7d4577a8d2a745c20f290d489ac7f2c5ca6f0ba2d7
@@ -54,6 +54,6 @@ class LHS::Item < LHS::Proxy
54
54
  return _data unless _record.item_key
55
55
  nested_data = _data.dig(*_record.item_key)
56
56
  return _data unless nested_data
57
- nested_data
57
+ LHS::Data.new(nested_data, _data._parent, _record, _data._request, _data._endpoint)
58
58
  end
59
59
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LHS
4
- VERSION = '19.4.0'
4
+ VERSION = '19.4.1'
5
5
  end
@@ -11,7 +11,7 @@ describe LHS::Record do
11
11
  end
12
12
  end
13
13
 
14
- let(:json_body) do
14
+ let(:location_response) do
15
15
  {
16
16
  response: {
17
17
  location: {
@@ -22,13 +22,13 @@ describe LHS::Record do
22
22
  end
23
23
 
24
24
  let(:stub_request_by_id) do
25
- stub_request(:get, "http://uberall/location/1")
26
- .to_return(body: json_body)
25
+ stub_request(:get, 'http://uberall/location/1')
26
+ .to_return(body: location_response)
27
27
  end
28
28
 
29
29
  let(:stub_request_by_get_parameters) do
30
- stub_request(:get, "http://uberall/location?identifier=1&limit=1")
31
- .to_return(body: json_body)
30
+ stub_request(:get, 'http://uberall/location?identifier=1&limit=1')
31
+ .to_return(body: location_response)
32
32
  end
33
33
 
34
34
  it 'uses configured item_key to unwrap response data for find' do
@@ -42,4 +42,40 @@ describe LHS::Record do
42
42
  location = Location.find_by(identifier: 1)
43
43
  expect(location.id).to eq 1
44
44
  end
45
+
46
+ describe 'Holding on to request object' do
47
+ let(:account_response) do
48
+ { id: 1 }.to_json
49
+ end
50
+
51
+ let(:stub_location_by_id) do
52
+ stub_request(:get, 'http://uberall/location/1')
53
+ .to_return(headers: { 'X-Custom-Header' => 'rspec' }, body: location_response)
54
+ end
55
+
56
+ let(:stub_account_by_id) do
57
+ stub_request(:get, 'http://yext/account/1')
58
+ .to_return(headers: { 'X-Custom-Header' => 'rspec' }, body: account_response)
59
+ end
60
+
61
+ before do
62
+ class Account < LHS::Record
63
+ endpoint 'http://yext/account'
64
+ endpoint 'http://yext/account/{id}'
65
+ end
66
+
67
+ stub_location_by_id
68
+ stub_account_by_id
69
+ end
70
+
71
+ it 'preserves request object for nested items' do
72
+ location = Location.find(1)
73
+ expect(location._request).to be_present
74
+ end
75
+
76
+ it 'preserves request object for unnested items' do
77
+ account = Account.find(1)
78
+ expect(account._request).to be_present
79
+ end
80
+ end
45
81
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhs
3
3
  version: !ruby/object:Gem::Version
4
- version: 19.4.0
4
+ version: 19.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://github.com/local-ch/lhs/graphs/contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-19 00:00:00.000000000 Z
11
+ date: 2019-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -480,7 +480,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
480
480
  requirements:
481
481
  - Ruby >= 2.3.0
482
482
  rubyforge_project:
483
- rubygems_version: 2.7.8
483
+ rubygems_version: 2.7.6
484
484
  signing_key:
485
485
  specification_version: 4
486
486
  summary: 'REST services accelerator: Rails gem providing an easy, active-record-like