paginate-responder 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -1
- data/README.md +2 -0
- data/lib/paginate-responder.rb +0 -1
- data/lib/paginate-responder/adapter/kaminari_adapter.rb +1 -1
- data/lib/paginate-responder/adapter/paginate_adapter.rb +1 -1
- data/lib/paginate-responder/version.rb +1 -1
- data/paginate-responder.gemspec +2 -0
- data/test/paginate_responder_test.rb +204 -4
- data/test/test_helper.rb +26 -0
- metadata +34 -6
- data/test/kaminari_responder_test.rb +0 -23
- data/test/pagination_tests.rb +0 -137
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -20,6 +20,8 @@ You will also need a pagination gem. `PaginateResponder` comes with adapters for
|
|
20
20
|
* [will_paginate](https://github.com/mislav/will_paginate) and
|
21
21
|
* [kaminari](https://github.com/amatsuda/kaminari).
|
22
22
|
|
23
|
+
It is recommended to use only on pagination gem at once.
|
24
|
+
|
23
25
|
## Usage
|
24
26
|
|
25
27
|
Add `Responders::PaginateResponder` to your responder chain:
|
data/lib/paginate-responder.rb
CHANGED
data/paginate-responder.gemspec
CHANGED
@@ -21,6 +21,8 @@ Gem::Specification.new do |gem|
|
|
21
21
|
|
22
22
|
gem.add_development_dependency 'rake'
|
23
23
|
gem.add_development_dependency 'actionpack', '>= 3.2.0'
|
24
|
+
gem.add_development_dependency 'activerecord', '>= 3.2.0'
|
25
|
+
gem.add_development_dependency 'sqlite3'
|
24
26
|
gem.add_development_dependency 'minitest'
|
25
27
|
gem.add_development_dependency 'minitest-reporters', '>= 0.8.0'
|
26
28
|
gem.add_development_dependency 'will_paginate'
|
@@ -1,14 +1,214 @@
|
|
1
1
|
require 'test_helper.rb'
|
2
|
-
require 'pagination_tests'
|
3
2
|
|
4
|
-
|
3
|
+
GEM = ENV['GEM'].to_s.split ','
|
4
|
+
GEM = [ 'will_paginate' ] if GEM.empty?
|
5
|
+
puts "[INFO] Running tests with #{GEM.join(' and ')}."
|
5
6
|
|
6
7
|
class PaginateResponderTest < ActionController::TestCase
|
7
8
|
tests PaginateController
|
8
9
|
|
10
|
+
def array_resource
|
11
|
+
('AA'..'zz').to_a
|
12
|
+
end
|
13
|
+
|
14
|
+
GEM.each do |gem|
|
15
|
+
case gem
|
16
|
+
when 'will_paginate'
|
17
|
+
require 'will_paginate/array'
|
18
|
+
require 'will_paginate/active_record'
|
19
|
+
when 'kaminari'
|
20
|
+
require 'kaminari'
|
21
|
+
require 'kaminari/models/array_extension'
|
22
|
+
Kaminari::Hooks.init
|
23
|
+
|
24
|
+
Kaminari.configure do |config|
|
25
|
+
config.default_per_page = 50
|
26
|
+
config.max_per_page = 50
|
27
|
+
end
|
28
|
+
|
29
|
+
def array_resource
|
30
|
+
Kaminari.paginate_array ('AA'..'zz').to_a
|
31
|
+
end
|
32
|
+
else
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
9
36
|
def setup
|
10
|
-
@controller.resource =
|
37
|
+
@controller.resource = ArModel.scoped
|
38
|
+
end
|
39
|
+
def json; JSON[@response.body] end
|
40
|
+
|
41
|
+
def test_pagination
|
42
|
+
get :index, :format => :json
|
43
|
+
|
44
|
+
assert_equal 50, json.size
|
45
|
+
assert_equal (1..50).to_a, json
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_pagination_arr
|
49
|
+
@controller.resource = array_resource
|
50
|
+
get :index, :format => :json
|
51
|
+
|
52
|
+
assert_equal 50, json.size
|
53
|
+
assert_equal ('AA'..'zz').to_a[0..49], json
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_pagination_assoc
|
57
|
+
@controller.resource = ArModel.find(1).ar_assoc_models
|
58
|
+
get :index, :format => :json
|
59
|
+
|
60
|
+
assert_equal 5, json.size
|
61
|
+
assert_equal (1..5).to_a, json
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_pagination_page_2
|
65
|
+
get :index, :format => :json, :page => 2
|
66
|
+
|
67
|
+
assert_equal 50, json.size
|
68
|
+
assert_equal (51..100).to_a, json
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_pagination_arr_page_2
|
72
|
+
@controller.resource = array_resource
|
73
|
+
get :index, :format => :json, :page => 2
|
74
|
+
|
75
|
+
assert_equal 50, json.size
|
76
|
+
assert_equal ('AA'..'zz').to_a[50..99], json
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_pagination_per_page
|
80
|
+
get :index, :format => :json, :page => 1, :per_page => 10
|
81
|
+
|
82
|
+
assert_equal 10, json.size
|
83
|
+
assert_equal (1..10).to_a, json
|
11
84
|
end
|
12
85
|
|
13
|
-
|
86
|
+
|
87
|
+
def test_pagination_arr_per_page
|
88
|
+
@controller.resource = array_resource
|
89
|
+
get :index, :format => :json, :page => 1, :per_page => 10
|
90
|
+
|
91
|
+
assert_equal 10, json.size
|
92
|
+
assert_equal ('AA'..'zz').to_a[0..9], json
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_pagination_per_page_2
|
96
|
+
get :index, :format => :json, :page => 2, :per_page => 10
|
97
|
+
|
98
|
+
assert_equal 10, json.size
|
99
|
+
assert_equal (11..20).to_a, json
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_pagination_arr_per_page_2
|
103
|
+
@controller.resource = array_resource
|
104
|
+
get :index, :format => :json, :page => 2, :per_page => 10
|
105
|
+
|
106
|
+
assert_equal 10, json.size
|
107
|
+
assert_equal ('AA'..'zz').to_a[10..19], json
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_headers
|
111
|
+
get :index, :format => :json
|
112
|
+
|
113
|
+
assert_equal 3, response.links.size
|
114
|
+
|
115
|
+
assert_equal "first", response.links[0][:params][:rel]
|
116
|
+
assert_equal "http://test.host/index.json?page=1", response.links[0][:url]
|
117
|
+
|
118
|
+
assert_equal "next", response.links[1][:params][:rel]
|
119
|
+
assert_equal "http://test.host/index.json?page=2", response.links[1][:url]
|
120
|
+
|
121
|
+
assert_equal "last", response.links[2][:params][:rel]
|
122
|
+
assert_equal "http://test.host/index.json?page=14", response.links[2][:url]
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_headers_page_2
|
126
|
+
get :index, :format => :json, :page => 2
|
127
|
+
|
128
|
+
assert_equal 4, response.links.size
|
129
|
+
|
130
|
+
assert_equal "first", response.links[0][:params][:rel]
|
131
|
+
assert_equal "http://test.host/index.json?page=1", response.links[0][:url]
|
132
|
+
|
133
|
+
assert_equal "prev", response.links[1][:params][:rel]
|
134
|
+
assert_equal "http://test.host/index.json?page=1", response.links[1][:url]
|
135
|
+
|
136
|
+
assert_equal "next", response.links[2][:params][:rel]
|
137
|
+
assert_equal "http://test.host/index.json?page=3", response.links[2][:url]
|
138
|
+
|
139
|
+
assert_equal "last", response.links[3][:params][:rel]
|
140
|
+
assert_equal "http://test.host/index.json?page=14", response.links[3][:url]
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_headers_page_5
|
144
|
+
get :index, :format => :json, :page => 5
|
145
|
+
|
146
|
+
assert_equal 4, response.links.size
|
147
|
+
|
148
|
+
assert_equal "first", response.links[0][:params][:rel]
|
149
|
+
assert_equal "http://test.host/index.json?page=1", response.links[0][:url]
|
150
|
+
|
151
|
+
assert_equal "prev", response.links[1][:params][:rel]
|
152
|
+
assert_equal "http://test.host/index.json?page=4", response.links[1][:url]
|
153
|
+
|
154
|
+
assert_equal "next", response.links[2][:params][:rel]
|
155
|
+
assert_equal "http://test.host/index.json?page=6", response.links[2][:url]
|
156
|
+
|
157
|
+
assert_equal "last", response.links[3][:params][:rel]
|
158
|
+
assert_equal "http://test.host/index.json?page=14", response.links[3][:url]
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_headers_last_page
|
162
|
+
get :index, :format => :json, :page => 14
|
163
|
+
|
164
|
+
assert_equal 3, response.links.size
|
165
|
+
|
166
|
+
assert_equal "first", response.links[0][:params][:rel]
|
167
|
+
assert_equal "http://test.host/index.json?page=1", response.links[0][:url]
|
168
|
+
|
169
|
+
assert_equal "prev", response.links[1][:params][:rel]
|
170
|
+
assert_equal "http://test.host/index.json?page=13", response.links[1][:url]
|
171
|
+
|
172
|
+
assert_equal "last", response.links[2][:params][:rel]
|
173
|
+
assert_equal "http://test.host/index.json?page=14", response.links[2][:url]
|
174
|
+
end
|
175
|
+
|
176
|
+
def test_headers_page_before_last_page
|
177
|
+
get :index, :format => :json, :page => 13
|
178
|
+
|
179
|
+
assert_equal 4, response.links.size
|
180
|
+
|
181
|
+
assert_equal "first", response.links[0][:params][:rel]
|
182
|
+
assert_equal "http://test.host/index.json?page=1", response.links[0][:url]
|
183
|
+
|
184
|
+
assert_equal "prev", response.links[1][:params][:rel]
|
185
|
+
assert_equal "http://test.host/index.json?page=12", response.links[1][:url]
|
186
|
+
|
187
|
+
assert_equal "next", response.links[2][:params][:rel]
|
188
|
+
assert_equal "http://test.host/index.json?page=14", response.links[2][:url]
|
189
|
+
|
190
|
+
assert_equal "last", response.links[3][:params][:rel]
|
191
|
+
assert_equal "http://test.host/index.json?page=14", response.links[3][:url]
|
192
|
+
end
|
193
|
+
|
194
|
+
def test_headers_per_page
|
195
|
+
get :index, :format => :json, :page => 1, :per_page => 10
|
196
|
+
|
197
|
+
assert_equal 3, response.links.size
|
198
|
+
|
199
|
+
assert_equal "first", response.links[0][:params][:rel]
|
200
|
+
assert_equal "http://test.host/index.json?page=1&per_page=10", response.links[0][:url]
|
201
|
+
|
202
|
+
assert_equal "next", response.links[1][:params][:rel]
|
203
|
+
assert_equal "http://test.host/index.json?page=2&per_page=10", response.links[1][:url]
|
204
|
+
|
205
|
+
assert_equal "last", response.links[2][:params][:rel]
|
206
|
+
assert_equal "http://test.host/index.json?page=68&per_page=10", response.links[2][:url]
|
207
|
+
end
|
208
|
+
|
209
|
+
def test_headers_total_pages
|
210
|
+
get :index, :format => :json
|
211
|
+
|
212
|
+
assert_equal "14", response.headers["X-Total-Pages"]
|
213
|
+
end
|
14
214
|
end
|
data/test/test_helper.rb
CHANGED
@@ -8,6 +8,7 @@ ENV["RAILS_ENV"] = "test"
|
|
8
8
|
|
9
9
|
require 'active_support'
|
10
10
|
require 'action_controller'
|
11
|
+
require 'active_record'
|
11
12
|
require 'minitest/reporters'
|
12
13
|
MiniTest::Reporters.use!
|
13
14
|
|
@@ -24,6 +25,31 @@ class ActiveSupport::TestCase
|
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
28
|
+
class ArModel < ActiveRecord::Base
|
29
|
+
has_many :ar_assoc_models
|
30
|
+
def as_json(opts = {}); self.id end
|
31
|
+
end
|
32
|
+
|
33
|
+
class ArAssocModel < ActiveRecord::Base
|
34
|
+
def as_json(opts = {}); self.id end
|
35
|
+
end
|
36
|
+
|
37
|
+
ActiveRecord::Base.establish_connection(
|
38
|
+
:adapter => 'sqlite3',
|
39
|
+
:database => ':memory:'
|
40
|
+
)
|
41
|
+
ActiveRecord::Base.connection.execute(
|
42
|
+
'CREATE TABLE ar_models (id INTEGER PRIMARY KEY AUTOINCREMENT);')
|
43
|
+
ActiveRecord::Base.connection.execute(
|
44
|
+
'CREATE TABLE ar_assoc_models (id INTEGER PRIMARY KEY AUTOINCREMENT, ar_model_id INTEGER);')
|
45
|
+
676.times do
|
46
|
+
ArModel.create!.tap do |ar_model|
|
47
|
+
5.times do
|
48
|
+
ar_model.ar_assoc_models.create!
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
27
53
|
class TestResponder < ActionController::Responder
|
28
54
|
include Responders::PaginateResponder
|
29
55
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paginate-responder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-03-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack-link_headers
|
@@ -59,6 +59,38 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 3.2.0
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: activerecord
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 3.2.0
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 3.2.0
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: sqlite3
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
62
94
|
- !ruby/object:Gem::Dependency
|
63
95
|
name: minitest
|
64
96
|
requirement: !ruby/object:Gem::Requirement
|
@@ -144,9 +176,7 @@ files:
|
|
144
176
|
- lib/paginate-responder/version.rb
|
145
177
|
- lib/responders/paginate_responder.rb
|
146
178
|
- paginate-responder.gemspec
|
147
|
-
- test/kaminari_responder_test.rb
|
148
179
|
- test/paginate_responder_test.rb
|
149
|
-
- test/pagination_tests.rb
|
150
180
|
- test/test_helper.rb
|
151
181
|
homepage: ''
|
152
182
|
licenses: []
|
@@ -173,7 +203,5 @@ signing_key:
|
|
173
203
|
specification_version: 3
|
174
204
|
summary: A Rails pagination responder with link header support.
|
175
205
|
test_files:
|
176
|
-
- test/kaminari_responder_test.rb
|
177
206
|
- test/paginate_responder_test.rb
|
178
|
-
- test/pagination_tests.rb
|
179
207
|
- test/test_helper.rb
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'test_helper.rb'
|
2
|
-
require 'pagination_tests'
|
3
|
-
|
4
|
-
require 'kaminari/config'
|
5
|
-
require 'kaminari/helpers/paginator'
|
6
|
-
require 'kaminari/models/page_scope_methods'
|
7
|
-
require 'kaminari/models/configuration_methods'
|
8
|
-
require 'kaminari/models/array_extension'
|
9
|
-
|
10
|
-
Kaminari.configure do |config|
|
11
|
-
config.default_per_page = 50
|
12
|
-
config.max_per_page = 50
|
13
|
-
end
|
14
|
-
|
15
|
-
class KaminariResponderTest < ActionController::TestCase
|
16
|
-
tests PaginateController
|
17
|
-
|
18
|
-
def setup
|
19
|
-
@controller.resource = Kaminari.paginate_array(resource)
|
20
|
-
end
|
21
|
-
|
22
|
-
include PaginationTests
|
23
|
-
end
|
data/test/pagination_tests.rb
DELETED
@@ -1,137 +0,0 @@
|
|
1
|
-
module PaginationTests
|
2
|
-
def json; JSON[@response.body] end
|
3
|
-
def resource; ('AA'..'zz').to_a end
|
4
|
-
|
5
|
-
def test_pagination
|
6
|
-
get :index, :format => :json
|
7
|
-
|
8
|
-
assert_equal 50, json.size
|
9
|
-
assert_equal ('AA'..'zz').to_a[0..49], json
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_pagination_page_2
|
13
|
-
get :index, :format => :json, :page => 2
|
14
|
-
|
15
|
-
assert_equal 50, json.size
|
16
|
-
assert_equal ('AA'..'zz').to_a[50..99], json
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_pagination_per_page
|
20
|
-
get :index, :format => :json, :page => 1, :per_page => 10
|
21
|
-
|
22
|
-
assert_equal 10, json.size
|
23
|
-
assert_equal ('AA'..'zz').to_a[0..9], json
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_pagination_per_page_2
|
27
|
-
get :index, :format => :json, :page => 2, :per_page => 10
|
28
|
-
|
29
|
-
assert_equal 10, json.size
|
30
|
-
assert_equal ('AA'..'zz').to_a[10..19], json
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_headers
|
34
|
-
get :index, :format => :json
|
35
|
-
|
36
|
-
assert_equal 3, response.links.size
|
37
|
-
|
38
|
-
assert_equal "first", response.links[0][:params][:rel]
|
39
|
-
assert_equal "http://test.host/index.json?page=1", response.links[0][:url]
|
40
|
-
|
41
|
-
assert_equal "next", response.links[1][:params][:rel]
|
42
|
-
assert_equal "http://test.host/index.json?page=2", response.links[1][:url]
|
43
|
-
|
44
|
-
assert_equal "last", response.links[2][:params][:rel]
|
45
|
-
assert_equal "http://test.host/index.json?page=14", response.links[2][:url]
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_headers_page_2
|
49
|
-
get :index, :format => :json, :page => 2
|
50
|
-
|
51
|
-
assert_equal 4, response.links.size
|
52
|
-
|
53
|
-
assert_equal "first", response.links[0][:params][:rel]
|
54
|
-
assert_equal "http://test.host/index.json?page=1", response.links[0][:url]
|
55
|
-
|
56
|
-
assert_equal "prev", response.links[1][:params][:rel]
|
57
|
-
assert_equal "http://test.host/index.json?page=1", response.links[1][:url]
|
58
|
-
|
59
|
-
assert_equal "next", response.links[2][:params][:rel]
|
60
|
-
assert_equal "http://test.host/index.json?page=3", response.links[2][:url]
|
61
|
-
|
62
|
-
assert_equal "last", response.links[3][:params][:rel]
|
63
|
-
assert_equal "http://test.host/index.json?page=14", response.links[3][:url]
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_headers_page_5
|
67
|
-
get :index, :format => :json, :page => 5
|
68
|
-
|
69
|
-
assert_equal 4, response.links.size
|
70
|
-
|
71
|
-
assert_equal "first", response.links[0][:params][:rel]
|
72
|
-
assert_equal "http://test.host/index.json?page=1", response.links[0][:url]
|
73
|
-
|
74
|
-
assert_equal "prev", response.links[1][:params][:rel]
|
75
|
-
assert_equal "http://test.host/index.json?page=4", response.links[1][:url]
|
76
|
-
|
77
|
-
assert_equal "next", response.links[2][:params][:rel]
|
78
|
-
assert_equal "http://test.host/index.json?page=6", response.links[2][:url]
|
79
|
-
|
80
|
-
assert_equal "last", response.links[3][:params][:rel]
|
81
|
-
assert_equal "http://test.host/index.json?page=14", response.links[3][:url]
|
82
|
-
end
|
83
|
-
|
84
|
-
def test_headers_last_page
|
85
|
-
get :index, :format => :json, :page => 14
|
86
|
-
|
87
|
-
assert_equal 3, response.links.size
|
88
|
-
|
89
|
-
assert_equal "first", response.links[0][:params][:rel]
|
90
|
-
assert_equal "http://test.host/index.json?page=1", response.links[0][:url]
|
91
|
-
|
92
|
-
assert_equal "prev", response.links[1][:params][:rel]
|
93
|
-
assert_equal "http://test.host/index.json?page=13", response.links[1][:url]
|
94
|
-
|
95
|
-
assert_equal "last", response.links[2][:params][:rel]
|
96
|
-
assert_equal "http://test.host/index.json?page=14", response.links[2][:url]
|
97
|
-
end
|
98
|
-
|
99
|
-
def test_headers_page_before_last_page
|
100
|
-
get :index, :format => :json, :page => 13
|
101
|
-
|
102
|
-
assert_equal 4, response.links.size
|
103
|
-
|
104
|
-
assert_equal "first", response.links[0][:params][:rel]
|
105
|
-
assert_equal "http://test.host/index.json?page=1", response.links[0][:url]
|
106
|
-
|
107
|
-
assert_equal "prev", response.links[1][:params][:rel]
|
108
|
-
assert_equal "http://test.host/index.json?page=12", response.links[1][:url]
|
109
|
-
|
110
|
-
assert_equal "next", response.links[2][:params][:rel]
|
111
|
-
assert_equal "http://test.host/index.json?page=14", response.links[2][:url]
|
112
|
-
|
113
|
-
assert_equal "last", response.links[3][:params][:rel]
|
114
|
-
assert_equal "http://test.host/index.json?page=14", response.links[3][:url]
|
115
|
-
end
|
116
|
-
|
117
|
-
def test_headers_per_page
|
118
|
-
get :index, :format => :json, :page => 1, :per_page => 10
|
119
|
-
|
120
|
-
assert_equal 3, response.links.size
|
121
|
-
|
122
|
-
assert_equal "first", response.links[0][:params][:rel]
|
123
|
-
assert_equal "http://test.host/index.json?page=1&per_page=10", response.links[0][:url]
|
124
|
-
|
125
|
-
assert_equal "next", response.links[1][:params][:rel]
|
126
|
-
assert_equal "http://test.host/index.json?page=2&per_page=10", response.links[1][:url]
|
127
|
-
|
128
|
-
assert_equal "last", response.links[2][:params][:rel]
|
129
|
-
assert_equal "http://test.host/index.json?page=68&per_page=10", response.links[2][:url]
|
130
|
-
end
|
131
|
-
|
132
|
-
def test_headers_total_pages
|
133
|
-
get :index, :format => :json
|
134
|
-
|
135
|
-
assert_equal "14", response.headers["X-Total-Pages"]
|
136
|
-
end
|
137
|
-
end
|