lhs 3.1.0 → 3.1.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
  SHA1:
3
- metadata.gz: 4b4d8da57cb83a4edce0d5a3ced7289528fc3aeb
4
- data.tar.gz: cd8ca6b468931ce8a677ee0ec686a04c05798d75
3
+ metadata.gz: f4f70cff889440ba4d2bca3c7b4d9480a763a2af
4
+ data.tar.gz: b8d18ad5a5a3951b24d96e9de37073fbd199267a
5
5
  SHA512:
6
- metadata.gz: 4f4f26c5cc042bf73e69c0ff021e5ce5b32d4fabf5afe8b692b5a6ececad255759aa86eda2d78a21031f0bca8481769bce809ebf45535c8eab478b8fdbea37e0
7
- data.tar.gz: 9672198becdb370e7775f8a922e613ee1ee7f28936f13672b936619e582c0cec3127bec258250e2dd14fa24db439e25d02af25b2a662d34cffd81e7faf1e2f58
6
+ metadata.gz: eebcb68bb74d56f301e44928874e72fc9e02c6754a21bd4a92bdec2200d26de45e49199bfc29366e2b3e8063ee28108eaf1cb3d9df1040e6c5f5a7027c09f323
7
+ data.tar.gz: 1a402c99a72282ecac133bb3de3627851cbe9ee79378ab8dbac9792fdaa4aff429064d653b7e011cbe1e0c3e6ccf850c035ccb76bcbcd17e62f776c599e743f1
@@ -16,7 +16,7 @@ class LHS::Record
16
16
 
17
17
  def includes(*args)
18
18
  name = "#{self}#{args.object_id}"
19
- constant = Object.const_set(name, self)
19
+ constant = Object.const_set(name.demodulize, self)
20
20
  class_clone = constant
21
21
  class_clone.endpoints = endpoints
22
22
  class_clone.mapping = mapping
@@ -1,3 +1,3 @@
1
1
  module LHS
2
- VERSION = "3.1.0"
2
+ VERSION = "3.1.1"
3
3
  end
@@ -0,0 +1,38 @@
1
+ require 'rails_helper'
2
+
3
+ describe LHS::Collection do
4
+ let(:datastore) { 'http://local.ch/v2' }
5
+ let(:items) { [{ name: 'Steve' }] }
6
+ let(:collection) { Account.where }
7
+
8
+ before(:each) do
9
+ LHC.config.placeholder('datastore', datastore)
10
+ class Account < LHS::Record
11
+ endpoint ':datastore/accounts'
12
+ end
13
+ stub_request(:get, "http://local.ch/v2/accounts")
14
+ .to_return(body: response_data.to_json)
15
+ end
16
+
17
+ context 'plain array' do
18
+ let(:response_data) do
19
+ items
20
+ end
21
+
22
+ it 'initalises a collection' do
23
+ expect(collection.first.name).to eq 'Steve'
24
+ end
25
+ end
26
+
27
+ context 'items key' do
28
+ let(:response_data) do
29
+ {
30
+ items: items
31
+ }
32
+ end
33
+
34
+ it 'initalises a collection when reponse contains a key items containing an array of items' do
35
+ expect(collection.first.name).to eq 'Steve'
36
+ end
37
+ end
38
+ end
@@ -189,4 +189,24 @@ describe LHS::Record do
189
189
  expect(feedback.campaign.href).to be
190
190
  end
191
191
  end
192
+
193
+ context 'modules' do
194
+ before(:each) do
195
+ module Services
196
+ class LocalEntry < LHS::Record
197
+ endpoint ':datastore/local-entries'
198
+ end
199
+
200
+ class Feedback < LHS::Record
201
+ endpoint ':datastore/feedbacks'
202
+ end
203
+ end
204
+ stub_request(:get, "http://local.ch/v2/feedbacks?id=123")
205
+ .to_return(body: [].to_json)
206
+ end
207
+
208
+ it 'works with modules' do
209
+ Services::Feedback.includes(campaign: :entry).find(123)
210
+ end
211
+ end
192
212
  end
@@ -26,7 +26,7 @@ describe LHS::Record do
26
26
  endpoint ':datastore/feedbacks'
27
27
  end
28
28
  stub_request(:get, 'http://local.ch/v2/feedbacks?entry_id=1')
29
- .and_return(body: body_json)
29
+ .to_return(body: body_json)
30
30
  end
31
31
 
32
32
  it 'responds to limit_value' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhs
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://github.com/local-ch/lhs/graphs/contributors
@@ -177,6 +177,7 @@ files:
177
177
  - lib/lhs/version.rb
178
178
  - script/ci/build.sh
179
179
  - spec/.DS_Store
180
+ - spec/collection/collection_items_spec.rb
180
181
  - spec/collection/delegate_spec.rb
181
182
  - spec/collection/enumerable_spec.rb
182
183
  - spec/collection/meta_data_spec.rb
@@ -297,6 +298,7 @@ specification_version: 4
297
298
  summary: Rails gem providing an easy, active-record-like interface to use http backend
298
299
  services
299
300
  test_files:
301
+ - spec/collection/collection_items_spec.rb
300
302
  - spec/collection/delegate_spec.rb
301
303
  - spec/collection/enumerable_spec.rb
302
304
  - spec/collection/meta_data_spec.rb