lhs 1.5.0 → 1.6.0
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/data.rb +28 -0
- data/lib/lhs/version.rb +1 -1
- data/spec/data/pagination_spec.rb +60 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65096e7eca42fba6bce1bba3e3dce4f9f7f21afd
|
4
|
+
data.tar.gz: c3b858f6d6cb0acd9cf49ca64999afc9c1b356b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c312138a69a33db110c39ff6718829de163c3d43117b8e6b1b7733f8f53b4b85aa775dc19c563d115295c2907ae4489cda7e3cb1f137bae27f47273feb4c4e52
|
7
|
+
data.tar.gz: 479add7a1d5139cc9629c0ec057965b95cbf10dd92adbe1cb2a8a20ee3f01bece8513340f040edcaee9421b4e8716302d6e988d83dce78b9b2d590b892bd6909
|
data/lib/lhs/data.rb
CHANGED
@@ -33,6 +33,34 @@ class LHS::Data
|
|
33
33
|
_root._service
|
34
34
|
end
|
35
35
|
|
36
|
+
def current_page
|
37
|
+
offset + 1
|
38
|
+
end
|
39
|
+
|
40
|
+
def first_page
|
41
|
+
1
|
42
|
+
end
|
43
|
+
|
44
|
+
def last_page
|
45
|
+
total_pages
|
46
|
+
end
|
47
|
+
|
48
|
+
def prev_page
|
49
|
+
current_page - 1
|
50
|
+
end
|
51
|
+
|
52
|
+
def next_page
|
53
|
+
current_page + 1
|
54
|
+
end
|
55
|
+
|
56
|
+
def limit_value
|
57
|
+
limit
|
58
|
+
end
|
59
|
+
|
60
|
+
def total_pages
|
61
|
+
total / limit
|
62
|
+
end
|
63
|
+
|
36
64
|
protected
|
37
65
|
|
38
66
|
# Use existing mapping to provide data
|
data/lib/lhs/version.rb
CHANGED
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe LHS::Data do
|
4
|
+
context 'pagination' do
|
5
|
+
let(:datastore) { 'http://local.ch/v2' }
|
6
|
+
let(:record) { Feedback.where(entry_id: 1) }
|
7
|
+
let(:total) { 200 }
|
8
|
+
let(:total_pages) { total / limit }
|
9
|
+
let(:current_page) { offset + 1 }
|
10
|
+
let(:prev_page) { current_page - 1 }
|
11
|
+
let(:next_page) { current_page + 1 }
|
12
|
+
let(:offset) { 0 }
|
13
|
+
let(:limit) { 10 }
|
14
|
+
let(:body_json) do
|
15
|
+
{
|
16
|
+
items: [],
|
17
|
+
total: total,
|
18
|
+
offset: offset,
|
19
|
+
limit: limit
|
20
|
+
}.to_json
|
21
|
+
end
|
22
|
+
|
23
|
+
before(:each) do
|
24
|
+
LHC.config.placeholder('datastore', datastore)
|
25
|
+
class Feedback < LHS::Service
|
26
|
+
endpoint ':datastore/feedbacks'
|
27
|
+
end
|
28
|
+
stub_request(:get, 'http://local.ch/v2/feedbacks?entry_id=1')
|
29
|
+
.to_return(body: body_json)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'responds to limit_value' do
|
33
|
+
expect(record.limit_value).to eq(limit)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'responds to total_pages' do
|
37
|
+
expect(record.total_pages).to eq(total_pages)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'responds to current_page' do
|
41
|
+
expect(record.current_page).to eq(current_page)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'responds to first_page' do
|
45
|
+
expect(record.first_page).to eq(1)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'responds to last_page' do
|
49
|
+
expect(record.last_page).to eq(total_pages)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'responds to prev_page' do
|
53
|
+
expect(record.prev_page).to eq(prev_page)
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'responds to next_page' do
|
57
|
+
expect(record.next_page).to eq(next_page)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
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: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- local.ch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lhc
|
@@ -167,6 +167,7 @@ files:
|
|
167
167
|
- spec/data/collection_spec.rb
|
168
168
|
- spec/data/item_spec.rb
|
169
169
|
- spec/data/merge_spec.rb
|
170
|
+
- spec/data/pagination_spec.rb
|
170
171
|
- spec/data/raw_spec.rb
|
171
172
|
- spec/data/respond_to_spec.rb
|
172
173
|
- spec/data/root_spec.rb
|
@@ -279,6 +280,7 @@ test_files:
|
|
279
280
|
- spec/data/collection_spec.rb
|
280
281
|
- spec/data/item_spec.rb
|
281
282
|
- spec/data/merge_spec.rb
|
283
|
+
- spec/data/pagination_spec.rb
|
282
284
|
- spec/data/raw_spec.rb
|
283
285
|
- spec/data/respond_to_spec.rb
|
284
286
|
- spec/data/root_spec.rb
|