lhs 20.1.2 → 20.1.3.pre.paginationfix.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/pagination/base.rb +7 -1
- data/lib/lhs/version.rb +1 -1
- data/spec/record/pagination_spec.rb +22 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01b93ba0d7073ad916d4af31c05e3739d095729d17691d07473374547d589917
|
4
|
+
data.tar.gz: 6a1f7462a292f695c45b1b0d6659415b75cdcbc282b9cdd6740cbe2a24245ab8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b1834964ca5704e3e3170933127fcb1dfcd92f19293f1b87a64374387965f1f8f0ed13e543f1959b8aa5292a940706f1f0fa524bfff465b47a9c5c5459a052d
|
7
|
+
data.tar.gz: c9f9f5c5dc3b7ba0f1759080442f4bc80735ac8e2f664ecf9608ed5b345fb0a565858e03ffc2aa1ad88d50af76efba66cb66361d58ccf39884dd45e86ac1ac06
|
data/lib/lhs/pagination/base.rb
CHANGED
@@ -23,7 +23,13 @@ module LHS::Pagination
|
|
23
23
|
alias count total
|
24
24
|
|
25
25
|
def limit
|
26
|
-
data._raw.dig(*_record.limit_key(:body))
|
26
|
+
limit_value = data._raw.dig(*_record.limit_key(:body))
|
27
|
+
requested_limit = data._request.params.dig(*_record.limit_key(:params))
|
28
|
+
if limit_value < requested_limit
|
29
|
+
requested_limit
|
30
|
+
else
|
31
|
+
limit_value || DEFAULT_LIMIT
|
32
|
+
end
|
27
33
|
end
|
28
34
|
|
29
35
|
def offset
|
data/lib/lhs/version.rb
CHANGED
@@ -67,5 +67,27 @@ describe LHS::Record do
|
|
67
67
|
expect(record.total_pages).to eq(28)
|
68
68
|
end
|
69
69
|
end
|
70
|
+
|
71
|
+
context 'total_pages calculation for last page' do
|
72
|
+
before do
|
73
|
+
class Search < LHS::Record
|
74
|
+
configuration pagination_strategy: :start, total_key: :totalResult, pagination_key: :start, limit_key: { body: :size, parameter: :limit }
|
75
|
+
endpoint 'https://search'
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'provides the correct number of total pages for the last page' do
|
80
|
+
stub_request(:get, "https://search/?limit=10&start=11")
|
81
|
+
.to_return(body: {
|
82
|
+
size: 4,
|
83
|
+
totalResult: 14,
|
84
|
+
start: 11,
|
85
|
+
items: [11,12,13,14]
|
86
|
+
}.to_json)
|
87
|
+
|
88
|
+
results = Search.page(2).limit(10).fetch
|
89
|
+
expect(results.total_pages).to eq 2
|
90
|
+
end
|
91
|
+
end
|
70
92
|
end
|
71
93
|
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: 20.1.
|
4
|
+
version: 20.1.3.pre.paginationfix.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-09-
|
11
|
+
date: 2019-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -525,12 +525,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
525
525
|
version: 2.3.0
|
526
526
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
527
527
|
requirements:
|
528
|
-
- - "
|
528
|
+
- - ">"
|
529
529
|
- !ruby/object:Gem::Version
|
530
|
-
version:
|
530
|
+
version: 1.3.1
|
531
531
|
requirements:
|
532
532
|
- Ruby >= 2.3.0
|
533
|
-
|
533
|
+
rubyforge_project:
|
534
|
+
rubygems_version: 2.7.8
|
534
535
|
signing_key:
|
535
536
|
specification_version: 4
|
536
537
|
summary: 'REST services accelerator: Rails gem providing an easy, active-record-like
|