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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2dbafc18cad6e10d1093d94960b14b8e1109c8b9
4
- data.tar.gz: 66807f1315bf189315159ad269e646768fac021f
3
+ metadata.gz: 98521af773941c3f0a5b2eca08ec3658433e3d0b
4
+ data.tar.gz: 3d8cbe19193e14d23abaea15fa1a95b34fbd5274
5
5
  SHA512:
6
- metadata.gz: 0af92d79ae09294eba20525e72802a42c4eb9d9a312d62da47046e3c56a656dc2d950d92fc9ef5d69a8fe5026b7da30a20edb13a0998b83ed1560a7dae8f11c2
7
- data.tar.gz: 51f0cccacfba24fa06ef01eb1d3c031f12e4ed5cb76ee2ae44e40c64dabe6a1a8b2c882bfa938cab74d21e68773c3a15c9cf77f9958789df1461f8ae2e5463f6
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
- response.link(controller.url_for(request.params.merge(:page => page)), :rel => rel)
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!
@@ -1,8 +1,8 @@
1
1
  module PaginateResponder
2
2
  module VERSION
3
3
  MAJOR = 1
4
- MINOR = 4
5
- PATCH = 2
4
+ MINOR = 5
5
+ PATCH = 0
6
6
  STAGE = nil
7
7
 
8
8
  def self.to_s
@@ -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 test_headers_total_pages
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 test_headers_total_count
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.2
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-02-11 00:00:00.000000000 Z
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
@@ -1,8 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in acfs.gemspec
4
- gemspec path: '../'
5
-
6
- gem 'actionpack', '~> 3.2.0'
7
- gem 'activerecord', '~> 3.2.0'
8
- gem 'minitest', '< 5'
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in acfs.gemspec
4
- gemspec path: '../'
5
-
6
- gem 'actionpack', '~> 4.0.0'
7
- gem 'activerecord', '~> 4.0.0'