lhs 15.2.3 → 15.2.4
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 +4 -4
- data/lib/lhs/concerns/record/find_by.rb +1 -1
- data/lib/lhs/version.rb +1 -1
- data/spec/record/dig_configuration_spec.rb +7 -1
- data/spec/record/find_by_spec.rb +19 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 065d4f6623803cb198313fad6600902190ee982a
|
4
|
+
data.tar.gz: f93e91649e7f464da69cdddb63e2ddd11f9ca204
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3f6b6026982ef4b1582395758e536e2c01b0e7e987063ce1872a493466999d341bbe664717c41fea6c5de031c6731c29ce6c57b4f0cd68fce7ea2e0bdfc013d
|
7
|
+
data.tar.gz: 22c1b2e5d8b62fa1b570143ee8e532b523e38f7e425a0aca5dd5d14a3a2e5c61b207bab261d376ff0b0b75f6b82ec3b43bb63ff89c6e4b17f67088d191d30f0a
|
@@ -23,7 +23,7 @@ class LHS::Record
|
|
23
23
|
def _find_by(params, options = {})
|
24
24
|
raise(LHS::Unprocessable.new, 'Cannot find Record without an ID') if params.any? && params.all? { |_, value| value.blank? }
|
25
25
|
options ||= {}
|
26
|
-
params = params.dup.merge(
|
26
|
+
params = params.dup.merge(limit_key(:parameter) => 1).merge(options.fetch(:params, {}))
|
27
27
|
data = request(options.merge(params: params))
|
28
28
|
if data && data._proxy.is_a?(LHS::Collection)
|
29
29
|
data.first || raise(LHC::NotFound.new('No item was found.', data._request.response))
|
data/lib/lhs/version.rb
CHANGED
@@ -3,7 +3,13 @@ require 'rails_helper'
|
|
3
3
|
describe LHS::Record do
|
4
4
|
before(:each) do
|
5
5
|
class Business < LHS::Record
|
6
|
-
configuration
|
6
|
+
configuration(
|
7
|
+
items_key: [:response, :businesses],
|
8
|
+
total_key: [:response, :count],
|
9
|
+
limit_key: { body: [:response, :max] },
|
10
|
+
pagination_key: { body: [:response, :offset] },
|
11
|
+
pagination_strategy: :offset
|
12
|
+
)
|
7
13
|
endpoint 'http://uberall/businesses'
|
8
14
|
end
|
9
15
|
end
|
data/spec/record/find_by_spec.rb
CHANGED
@@ -42,6 +42,25 @@ describe LHS::Record do
|
|
42
42
|
it 'returns nil if empty id' do
|
43
43
|
expect { Record.find_by(id: '') }.to raise_error LHS::Unprocessable
|
44
44
|
end
|
45
|
+
|
46
|
+
context 'when record has custom configurations for limit_key' do
|
47
|
+
before :each do
|
48
|
+
class Record < LHS::Record
|
49
|
+
endpoint '{+datastore}/feedbacks/{id}'
|
50
|
+
configuration(
|
51
|
+
limit_key: { body: %i[response max], parameter: :max }
|
52
|
+
)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'finds a single record with max parameter' do
|
57
|
+
stub_request(:get, "#{datastore}/feedbacks/z12f-3asm3ngals?max=1")
|
58
|
+
.to_return(status: 200, body: load_json(:feedback))
|
59
|
+
record = Record.find_by(id: 'z12f-3asm3ngals')
|
60
|
+
expect(record.source_id).to be_kind_of String
|
61
|
+
expect(record).to be_kind_of Record
|
62
|
+
end
|
63
|
+
end
|
45
64
|
end
|
46
65
|
|
47
66
|
context 'find_by!' do
|