lhs 19.0.0 → 19.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lhs/concerns/record/request.rb +2 -2
- data/lib/lhs/version.rb +1 -1
- data/spec/record/includes_all_spec.rb +41 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3877f76874bcb34f2627b1c88810a610fae7cc7c5eaf3398d8a13825896c84a2
|
4
|
+
data.tar.gz: 6640dcf74957e4cb8a526f07ec6411b327fc52d29eb5da8207b0cfa60efbb743
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efcafa00c531b5f8b91b13168daa5f9502f9d6aca3ec52ede815246e32052fa75f064099460fb2db9102be644c7d3219b78b23d441374612adf7aad181c16c96
|
7
|
+
data.tar.gz: 8e30bb7d0e5ceee64a03978d89c14f608a35f4f728940ea51dcae7f571bee1bf51e90695b9b86b9c3ec90df8aaddd249cc40e6c45517402205654e300e80d4a1
|
@@ -147,7 +147,7 @@ class LHS::Record
|
|
147
147
|
def extend_base_item_with_hash_of_items!(target, addition)
|
148
148
|
LHS::Collection.nest(input: target._raw, value: [], record: self)
|
149
149
|
if LHS::Collection.access(input: target._raw, record: self).empty?
|
150
|
-
LHS::Collection.nest(input: target._raw, value: addition.map(&:_raw), record: self)
|
150
|
+
LHS::Collection.nest(input: target._raw, value: addition.compact.map(&:_raw), record: self)
|
151
151
|
else
|
152
152
|
LHS::Collection.access(input: target._raw, record: self).each_with_index do |item, index|
|
153
153
|
item.merge!(addition[index])
|
@@ -242,7 +242,7 @@ class LHS::Record
|
|
242
242
|
load_and_merge_paginated_collection!(data, options)
|
243
243
|
elsif data.collection? && paginated?(data.first.try(:_raw))
|
244
244
|
load_and_merge_set_of_paginated_collections!(data, options)
|
245
|
-
elsif load_not_paginated_collection
|
245
|
+
elsif load_not_paginated_collection && data.collection?
|
246
246
|
warn('[Warning] "all" has been requested, but endpoint does not provide pagination meta data. If you just want to fetch the first response, use "where" or "fetch".')
|
247
247
|
load_and_merge_not_paginated_collection!(data, options)
|
248
248
|
end
|
data/lib/lhs/version.rb
CHANGED
@@ -523,4 +523,45 @@ describe LHS::Record do
|
|
523
523
|
end
|
524
524
|
end
|
525
525
|
end
|
526
|
+
|
527
|
+
context 'includes collection trough single item' do
|
528
|
+
|
529
|
+
before do
|
530
|
+
class Place < LHS::Record
|
531
|
+
endpoint 'https://places/{id}'
|
532
|
+
end
|
533
|
+
|
534
|
+
stub_request(:get, 'https://places/1')
|
535
|
+
.to_return(
|
536
|
+
body: {
|
537
|
+
customer: { href: 'https://customers/1' }
|
538
|
+
}.to_json
|
539
|
+
)
|
540
|
+
|
541
|
+
stub_request(:get, 'https://customers/1?limit=100')
|
542
|
+
.to_return(
|
543
|
+
body: {
|
544
|
+
addresses: { 'href': 'https://customer/1/addresses' }
|
545
|
+
}.to_json
|
546
|
+
)
|
547
|
+
|
548
|
+
stub_request(:get, 'https://customer/1/addresses?limit=100')
|
549
|
+
.to_return(
|
550
|
+
body: {
|
551
|
+
items: [
|
552
|
+
{ city: 'Zurich', no: 1 },
|
553
|
+
{ city: 'Zurich', no: 2 }
|
554
|
+
],
|
555
|
+
total: 2
|
556
|
+
}.to_json
|
557
|
+
)
|
558
|
+
end
|
559
|
+
|
560
|
+
it 'includes a collection trough a single item without exceptions' do
|
561
|
+
place = Place
|
562
|
+
.includes_all(customer: :addresses)
|
563
|
+
.find(1)
|
564
|
+
expect(place.customer.addresses.map(&:no)).to eq [1, 2]
|
565
|
+
end
|
566
|
+
end
|
526
567
|
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.0.
|
4
|
+
version: 19.0.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-
|
11
|
+
date: 2019-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -472,7 +472,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
472
472
|
requirements:
|
473
473
|
- Ruby >= 2.3.0
|
474
474
|
rubyforge_project:
|
475
|
-
rubygems_version: 2.7.
|
475
|
+
rubygems_version: 2.7.8
|
476
476
|
signing_key:
|
477
477
|
specification_version: 4
|
478
478
|
summary: 'REST services accelerator: Rails gem providing an easy, active-record-like
|