lhs 19.0.0 → 19.0.1

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: 77b527b1361f3271ef942872409972d6ad2b7e15110b46ef0ec4c538419d7356
4
- data.tar.gz: a20166a8a53f5997fc78ca86198c51adb89485e9b406ffc040016ca060050e9a
3
+ metadata.gz: 3877f76874bcb34f2627b1c88810a610fae7cc7c5eaf3398d8a13825896c84a2
4
+ data.tar.gz: 6640dcf74957e4cb8a526f07ec6411b327fc52d29eb5da8207b0cfa60efbb743
5
5
  SHA512:
6
- metadata.gz: 1685d5df2ad15049e2e9afb1977130782735b87f00fd3a3b4d586537aca791c9d0bbfb3dd914866b15aa2cbed4a0b94fc327174f6bd5e5bdb8bffe4e47769e0d
7
- data.tar.gz: 6b1bc8d53d681a6da347c2f42046192f245b4fab9e934291ee7d63d1644e4c313347c70b9b37d07e8bcb684b628d862304e1978d38ea2e1e831b0e37005dce9d
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LHS
4
- VERSION = '19.0.0'
4
+ VERSION = '19.0.1'
5
5
  end
@@ -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.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-02-25 00:00:00.000000000 Z
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.6
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