paginate-responder 1.4.2 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -5
- data/lib/paginate-responder/paginator.rb +4 -1
- data/lib/paginate-responder/version.rb +2 -2
- data/test/paginate_responder_test.rb +23 -2
- metadata +2 -4
- data/gemfiles/Gemfile.rails-3-2 +0 -8
- data/gemfiles/Gemfile.rails-4-0 +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98521af773941c3f0a5b2eca08ec3658433e3d0b
|
4
|
+
data.tar.gz: 3d8cbe19193e14d23abaea15fa1a95b34fbd5274
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f43de22a9d8eabde4bab441f842d517f0b99c9c108a8895467674c89d2afea88c93d1e48102504b2740a84eaeb9186f6d2c06a26eb656c1dc10e9b48f8a0eb9
|
7
|
+
data.tar.gz: f3756e605e2036a5bd5513b69743b94c0ee41476b1b8a59e3e5a6ce08e3e18aa96d107521b147b738b523649818e92c823896f1f1fd982538e67293c45b38cd6
|
data/.travis.yml
CHANGED
@@ -1,16 +1,13 @@
|
|
1
1
|
sudo: false
|
2
2
|
language: ruby
|
3
3
|
rvm:
|
4
|
+
- '2.3.0'
|
5
|
+
- '2.2'
|
4
6
|
- '2.1'
|
5
|
-
- '2.0'
|
6
|
-
- 1.9.3
|
7
|
-
- rbx
|
8
7
|
env:
|
9
8
|
- GEM=will_paginate
|
10
9
|
- GEM=kaminari
|
11
10
|
gemfile:
|
12
|
-
- gemfiles/Gemfile.rails-3-2
|
13
|
-
- gemfiles/Gemfile.rails-4-0
|
14
11
|
- gemfiles/Gemfile.rails-4-1
|
15
12
|
- gemfiles/Gemfile.rails-4-2
|
16
13
|
- gemfiles/Gemfile.rails-head
|
@@ -42,10 +42,13 @@ module PaginateResponder
|
|
42
42
|
|
43
43
|
response.headers["X-Total-Pages"] = total_pages.to_s if total_pages
|
44
44
|
response.headers["X-Total-Count"] = total_count.to_s if total_count
|
45
|
+
response.headers["X-Per-Page"] = per_page.to_s
|
45
46
|
end
|
46
47
|
|
47
48
|
def link!(rel, page)
|
48
|
-
|
49
|
+
pagination_params = { :page => page }
|
50
|
+
pagination_params[:per_page] = per_page if request.params.has_key?(:per_page)
|
51
|
+
response.link(controller.url_for(request.params.merge(pagination_params)), :rel => rel)
|
49
52
|
end
|
50
53
|
|
51
54
|
def resource!
|
@@ -212,15 +212,36 @@ class PaginateResponderTest < ActionController::TestCase
|
|
212
212
|
assert_equal 'http://test.host/index.json?page=68&per_page=10', response.links[2][:url]
|
213
213
|
end
|
214
214
|
|
215
|
-
def
|
215
|
+
def test_headers_per_page_maximum
|
216
|
+
get :index, format: :json, page: 1, per_page: 100
|
217
|
+
|
218
|
+
assert_equal 3, response.links.size
|
219
|
+
|
220
|
+
assert_equal 'first', response.links[0][:params][:rel]
|
221
|
+
assert_equal 'http://test.host/index.json?page=1&per_page=50', response.links[0][:url]
|
222
|
+
|
223
|
+
assert_equal 'next', response.links[1][:params][:rel]
|
224
|
+
assert_equal 'http://test.host/index.json?page=2&per_page=50', response.links[1][:url]
|
225
|
+
|
226
|
+
assert_equal 'last', response.links[2][:params][:rel]
|
227
|
+
assert_equal 'http://test.host/index.json?page=14&per_page=50', response.links[2][:url]
|
228
|
+
end
|
229
|
+
|
230
|
+
def test_custom_headers_total_pages
|
216
231
|
get :index, format: :json
|
217
232
|
|
218
233
|
assert_equal '14', response.headers['X-Total-Pages']
|
219
234
|
end
|
220
235
|
|
221
|
-
def
|
236
|
+
def test_custom_headers_total_count
|
222
237
|
get :index, format: :json
|
223
238
|
|
224
239
|
assert_equal '676', response.headers['X-Total-Count']
|
225
240
|
end
|
241
|
+
|
242
|
+
def test_custom_headers_per_page
|
243
|
+
get :index, format: :json
|
244
|
+
|
245
|
+
assert_equal '50', response.headers['X-Per-Page']
|
246
|
+
end
|
226
247
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paginate-responder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Graichen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack-link_headers
|
@@ -149,8 +149,6 @@ files:
|
|
149
149
|
- LICENSE.txt
|
150
150
|
- README.md
|
151
151
|
- Rakefile
|
152
|
-
- gemfiles/Gemfile.rails-3-2
|
153
|
-
- gemfiles/Gemfile.rails-4-0
|
154
152
|
- gemfiles/Gemfile.rails-4-1
|
155
153
|
- gemfiles/Gemfile.rails-4-2
|
156
154
|
- gemfiles/Gemfile.rails-head
|
data/gemfiles/Gemfile.rails-3-2
DELETED