lhs 3.1.0 → 3.1.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/includes.rb +1 -1
- data/lib/lhs/version.rb +1 -1
- data/spec/collection/collection_items_spec.rb +38 -0
- data/spec/record/includes_spec.rb +20 -0
- data/spec/record/pagination_spec.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4f70cff889440ba4d2bca3c7b4d9480a763a2af
|
4
|
+
data.tar.gz: b8d18ad5a5a3951b24d96e9de37073fbd199267a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/lhs/version.rb
CHANGED
@@ -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
|
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.
|
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
|