clean_pagination 0.0.1
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +32 -0
- data/lib/clean_pagination/version.rb +3 -0
- data/lib/clean_pagination.rb +72 -0
- data/lib/tasks/clean_pagination_tasks.rake +4 -0
- data/test/clean_pagination_test.rb +251 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +29 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/application/index.html.erb +1 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +29 -0
- data/test/dummy/config/environments/production.rb +80 -0
- data/test/dummy/config/environments/test.rb +36 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +56 -0
- data/test/dummy/config/secrets.yml +20 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +5967 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/test_helper.rb +15 -0
- metadata +189 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7871f574a1cd0cc4500390a3dd1930ecb8609203
|
4
|
+
data.tar.gz: e61becc7ff88048882a36f9fd87745ec8f26ad0a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b6aac0a85646fddc51ec8ecab02c9cd43e33d8e3d41341cb7fec6981be975cba69e01aa89519d9a2c24fa28ae6dff01a6f904532dba5c8b62d2b746c41478e55
|
7
|
+
data.tar.gz: b2b57c95951311739b1d93d92bc2cb5df1413bb10fce058c33110c764b36d610748e2b65a79ab851737cc50e4c797581b3b0b5100d0542f90495a9030e105fa3
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2014 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'CleanPagination'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
Bundler::GemHelper.install_tasks
|
21
|
+
|
22
|
+
require 'rake/testtask'
|
23
|
+
|
24
|
+
Rake::TestTask.new(:test) do |t|
|
25
|
+
t.libs << 'lib'
|
26
|
+
t.libs << 'test'
|
27
|
+
t.pattern = 'test/**/*_test.rb'
|
28
|
+
t.verbose = false
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
task default: :test
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module CleanPagination
|
2
|
+
|
3
|
+
def paginate total_items, max_range_size
|
4
|
+
headers['Accept-Ranges'] = 'items'
|
5
|
+
headers['Range-Unit'] = 'items'
|
6
|
+
|
7
|
+
requested_from, requested_to = 0, total_items - 1
|
8
|
+
|
9
|
+
if request.headers['Range-Unit'] == 'items' &&
|
10
|
+
request.headers['Range'].present?
|
11
|
+
if request.headers['Range'] =~ /(\d+)-(\d+)/
|
12
|
+
requested_from, requested_to = $1.to_i, $2.to_i
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
if requested_from >= requested_to
|
17
|
+
response.status = 416
|
18
|
+
headers['Content-Range'] = "*/#{total_items}"
|
19
|
+
return
|
20
|
+
end
|
21
|
+
|
22
|
+
available_to = [requested_to,
|
23
|
+
total_items - 1,
|
24
|
+
requested_from + max_range_size - 1
|
25
|
+
].min
|
26
|
+
headers['Content-Range'] = "#{
|
27
|
+
requested_from
|
28
|
+
}-#{
|
29
|
+
available_to
|
30
|
+
}/#{
|
31
|
+
total_items < Float::INFINITY ? total_items : '*'
|
32
|
+
}"
|
33
|
+
|
34
|
+
available_limit = available_to - requested_from + 1
|
35
|
+
yield available_limit, requested_from
|
36
|
+
if available_limit < total_items && response.status == 200
|
37
|
+
response.status = 206
|
38
|
+
end
|
39
|
+
|
40
|
+
requested_limit = requested_to - requested_from + 1
|
41
|
+
|
42
|
+
links = []
|
43
|
+
if available_to < total_items - 1
|
44
|
+
links << "<#{request.path}>; rel=\"next\"; items=\"#{
|
45
|
+
available_to + 1
|
46
|
+
}-#{
|
47
|
+
available_to + requested_limit
|
48
|
+
}\""
|
49
|
+
|
50
|
+
links << "<#{request.path}>; rel=\"last\"; items=\"#{
|
51
|
+
# let rounding do the work
|
52
|
+
((total_items-1) / available_limit) * available_limit
|
53
|
+
}-#{
|
54
|
+
(((total_items-1) / available_limit) * available_limit) + requested_limit - 1
|
55
|
+
}\""
|
56
|
+
end
|
57
|
+
if requested_from > 0
|
58
|
+
previous_from = [0, requested_from - [requested_limit, max_range_size].min].max
|
59
|
+
|
60
|
+
links << "<#{request.path}>; rel=\"prev\"; items=\"#{
|
61
|
+
previous_from
|
62
|
+
}-#{
|
63
|
+
previous_from + requested_limit - 1
|
64
|
+
}\""
|
65
|
+
|
66
|
+
links << "<#{request.path}>; rel=\"first\"; items=\"0-#{requested_limit-1}\""
|
67
|
+
end
|
68
|
+
|
69
|
+
headers['Link'] = links.join ', '
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
@@ -0,0 +1,251 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
def parse_link_ranges header
|
4
|
+
links = Hash.new
|
5
|
+
(header || '').split(',').each do |link|
|
6
|
+
link =~ /rel="(.*)".*items="(.*)"/
|
7
|
+
links[$1] = $2
|
8
|
+
end
|
9
|
+
links
|
10
|
+
end
|
11
|
+
|
12
|
+
class ApplicationControllerTest < ActionController::TestCase
|
13
|
+
setup do
|
14
|
+
@controller.stubs(:total_items).returns 101
|
15
|
+
@controller.stubs(:max_range).returns 100
|
16
|
+
end
|
17
|
+
|
18
|
+
test 'rangeless request range works normally if max_range >= total' do
|
19
|
+
@controller.stubs(:total_items).returns 100
|
20
|
+
|
21
|
+
@controller.expects(:action).with(100, 0)
|
22
|
+
get :index
|
23
|
+
assert_equal 200, response.status
|
24
|
+
assert_equal 'items', response.headers['Accept-Ranges']
|
25
|
+
end
|
26
|
+
|
27
|
+
test 'rangeless request truncates if max_range < total' do
|
28
|
+
@controller.expects(:action).with(100, 0)
|
29
|
+
get :index
|
30
|
+
assert_equal 206, response.status
|
31
|
+
assert_equal 'items', response.headers['Accept-Ranges']
|
32
|
+
assert_equal '0-99/101', response.headers['Content-Range']
|
33
|
+
end
|
34
|
+
|
35
|
+
test 'an acceptable range succeeds' do
|
36
|
+
@request.headers['Range-Unit'] = 'items'
|
37
|
+
@request.headers['Range'] = "0-99"
|
38
|
+
|
39
|
+
@controller.expects(:action).with(100, 0)
|
40
|
+
get :index
|
41
|
+
assert_equal 206, response.status
|
42
|
+
assert_equal 'items', response.headers['Range-Unit']
|
43
|
+
assert_equal '0-99/101', response.headers['Content-Range']
|
44
|
+
end
|
45
|
+
|
46
|
+
test 'an oversized range is truncated' do
|
47
|
+
@request.headers['Range-Unit'] = 'items'
|
48
|
+
@request.headers['Range'] = "0-100"
|
49
|
+
|
50
|
+
get :index
|
51
|
+
assert_equal 206, response.status
|
52
|
+
assert_equal 'items', response.headers['Range-Unit']
|
53
|
+
assert_equal '0-99/101', response.headers['Content-Range']
|
54
|
+
end
|
55
|
+
|
56
|
+
test "passes along exceptional status codes" do
|
57
|
+
@request.headers['Range-Unit'] = 'items'
|
58
|
+
@request.headers['Range'] = "0-99"
|
59
|
+
|
60
|
+
[100, 301, 404, 500].each do |code|
|
61
|
+
@controller.stubs(:index_status).returns code
|
62
|
+
get :index
|
63
|
+
assert_equal code, response.status
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
test "reports infinite/unknown collection" do
|
68
|
+
@controller.stubs(:total_items).returns Float::INFINITY
|
69
|
+
|
70
|
+
@request.headers['Range-Unit'] = 'items'
|
71
|
+
@request.headers['Range'] = "0-9"
|
72
|
+
get :index
|
73
|
+
assert_equal '0-9/*', response.headers['Content-Range']
|
74
|
+
end
|
75
|
+
|
76
|
+
test "refuses offside ranges" do
|
77
|
+
@request.headers['Range-Unit'] = 'items'
|
78
|
+
@request.headers['Range'] = "1-0"
|
79
|
+
|
80
|
+
@controller.expects(:action).never
|
81
|
+
get :index
|
82
|
+
assert_equal 416, response.status
|
83
|
+
assert_equal '*/101', response.headers['Content-Range']
|
84
|
+
end
|
85
|
+
|
86
|
+
test "handles ranges beyond collection length via truncation" do
|
87
|
+
@request.headers['Range-Unit'] = 'items'
|
88
|
+
@request.headers['Range'] = "50-200"
|
89
|
+
|
90
|
+
@controller.expects(:action).with(51, 50)
|
91
|
+
get :index
|
92
|
+
|
93
|
+
assert_equal 206, response.status
|
94
|
+
assert_equal '50-100/101', response.headers['Content-Range']
|
95
|
+
end
|
96
|
+
|
97
|
+
test "includes link headers" do
|
98
|
+
@controller.stubs(:total_items).returns 100
|
99
|
+
|
100
|
+
@request.headers['Range-Unit'] = 'items'
|
101
|
+
@request.headers['Range'] = "20-29"
|
102
|
+
|
103
|
+
get :index
|
104
|
+
links = parse_link_ranges response.headers['Link']
|
105
|
+
|
106
|
+
assert_equal '30-39', links['next']
|
107
|
+
assert_equal '10-19', links['prev']
|
108
|
+
assert_equal '0-9', links['first']
|
109
|
+
assert_equal '90-99', links['last']
|
110
|
+
end
|
111
|
+
|
112
|
+
test "next page range can extend beyond last item" do
|
113
|
+
@controller.stubs(:total_items).returns 100
|
114
|
+
|
115
|
+
@request.headers['Range-Unit'] = 'items'
|
116
|
+
@request.headers['Range'] = "50-89"
|
117
|
+
|
118
|
+
get :index
|
119
|
+
links = parse_link_ranges response.headers['Link']
|
120
|
+
|
121
|
+
assert_equal '90-129', links['next']
|
122
|
+
end
|
123
|
+
|
124
|
+
test "previous page range cannot go negative" do
|
125
|
+
@controller.stubs(:total_items).returns 100
|
126
|
+
|
127
|
+
@request.headers['Range-Unit'] = 'items'
|
128
|
+
@request.headers['Range'] = "10-99"
|
129
|
+
|
130
|
+
get :index
|
131
|
+
links = parse_link_ranges response.headers['Link']
|
132
|
+
|
133
|
+
assert_equal '0-89', links['prev']
|
134
|
+
end
|
135
|
+
|
136
|
+
test "first page range always starts at zero" do
|
137
|
+
@controller.stubs(:total_items).returns 100
|
138
|
+
|
139
|
+
@request.headers['Range-Unit'] = 'items'
|
140
|
+
@request.headers['Range'] = "63-72"
|
141
|
+
|
142
|
+
get :index
|
143
|
+
links = parse_link_ranges response.headers['Link']
|
144
|
+
|
145
|
+
assert_equal '0-9', links['first']
|
146
|
+
end
|
147
|
+
|
148
|
+
test "last page range can extend beyond the last item" do
|
149
|
+
@controller.stubs(:total_items).returns 100
|
150
|
+
|
151
|
+
@request.headers['Range-Unit'] = 'items'
|
152
|
+
@request.headers['Range'] = "0-6"
|
153
|
+
|
154
|
+
get :index
|
155
|
+
links = parse_link_ranges response.headers['Link']
|
156
|
+
|
157
|
+
assert_equal '98-104', links['last']
|
158
|
+
end
|
159
|
+
|
160
|
+
test "shifts penultimate page to beginning, preserving length" do
|
161
|
+
@controller.stubs(:total_items).returns 100
|
162
|
+
|
163
|
+
@request.headers['Range-Unit'] = 'items'
|
164
|
+
@request.headers['Range'] = "10-49"
|
165
|
+
|
166
|
+
get :index
|
167
|
+
links = parse_link_ranges response.headers['Link']
|
168
|
+
|
169
|
+
assert_equal '0-39', links['prev']
|
170
|
+
assert_equal '0-39', links['first']
|
171
|
+
end
|
172
|
+
|
173
|
+
test "prev is the left inverse of next" do
|
174
|
+
@request.headers['Range-Unit'] = 'items'
|
175
|
+
|
176
|
+
100.times do
|
177
|
+
total_items = rand(1..20)
|
178
|
+
to = rand(1..total_items)
|
179
|
+
from = rand(0...to)
|
180
|
+
max_range = rand(1..20)
|
181
|
+
|
182
|
+
msg = "#{from}-#{to}/#{total_items} max_range=#{max_range}"
|
183
|
+
|
184
|
+
@controller.stubs(:total_items).returns total_items
|
185
|
+
@controller.stubs(:max_range).returns max_range
|
186
|
+
@request.headers['Range'] = "#{from}-#{to}"
|
187
|
+
get :index
|
188
|
+
|
189
|
+
links = parse_link_ranges response.headers['Link']
|
190
|
+
if links['next']
|
191
|
+
msg += " thence to #{links['next']}/#{total_items}"
|
192
|
+
@request.headers['Range'] = links['next']
|
193
|
+
get :index
|
194
|
+
|
195
|
+
links = parse_link_ranges response.headers['Link']
|
196
|
+
assert_equal "#{from}-#{to}", links['prev'], msg
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
test "for from > to-from, next is the right inverse of prev" do
|
202
|
+
@request.headers['Range-Unit'] = 'items'
|
203
|
+
|
204
|
+
100.times do
|
205
|
+
total_items = rand(1..20)
|
206
|
+
to = rand(1..total_items)
|
207
|
+
from = rand(to/2+1...to)
|
208
|
+
max_range = rand(1..20)
|
209
|
+
|
210
|
+
msg = "#{from}-#{to}/#{total_items} max_range=#{max_range}"
|
211
|
+
|
212
|
+
@controller.stubs(:total_items).returns total_items
|
213
|
+
@controller.stubs(:max_range).returns max_range
|
214
|
+
@request.headers['Range'] = "#{from}-#{to}"
|
215
|
+
get :index
|
216
|
+
|
217
|
+
links = parse_link_ranges response.headers['Link']
|
218
|
+
if links['prev']
|
219
|
+
msg += " thence to #{links['prev']}/#{total_items}"
|
220
|
+
@request.headers['Range'] = links['prev']
|
221
|
+
get :index
|
222
|
+
|
223
|
+
links = parse_link_ranges response.headers['Link']
|
224
|
+
assert_equal "#{from}-#{to}", links['next'], msg
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
test "omits prev and first links at start" do
|
230
|
+
@request.headers['Range-Unit'] = 'items'
|
231
|
+
@request.headers['Range'] = "0-9"
|
232
|
+
|
233
|
+
get :index
|
234
|
+
links = parse_link_ranges response.headers['Link']
|
235
|
+
|
236
|
+
assert_nil links['first']
|
237
|
+
assert_nil links['prev']
|
238
|
+
end
|
239
|
+
|
240
|
+
test "omits next and last links at end" do
|
241
|
+
@controller.stubs(:total_items).returns 100
|
242
|
+
@request.headers['Range-Unit'] = 'items'
|
243
|
+
@request.headers['Range'] = "90-99"
|
244
|
+
|
245
|
+
get :index
|
246
|
+
links = parse_link_ranges response.headers['Link']
|
247
|
+
|
248
|
+
assert_nil links['last']
|
249
|
+
assert_nil links['next']
|
250
|
+
end
|
251
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|
data/test/dummy/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class ApplicationController < ActionController::Base
|
2
|
+
# Prevent CSRF attacks by raising an exception.
|
3
|
+
# For APIs, you may want to use :null_session instead.
|
4
|
+
protect_from_forgery with: :exception
|
5
|
+
|
6
|
+
include CleanPagination
|
7
|
+
|
8
|
+
def index
|
9
|
+
paginate total_items, max_range do |limit, offset|
|
10
|
+
action limit, offset
|
11
|
+
render status: index_status
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def total_items
|
16
|
+
raise 'stub me'
|
17
|
+
end
|
18
|
+
|
19
|
+
def max_range
|
20
|
+
raise 'stub me'
|
21
|
+
end
|
22
|
+
|
23
|
+
def action limit, offset
|
24
|
+
end
|
25
|
+
|
26
|
+
def index_status
|
27
|
+
200
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<p>hi</p>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
|
6
|
+
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/test/dummy/bin/rake
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
Bundler.require(*Rails.groups)
|
6
|
+
require "clean_pagination"
|
7
|
+
|
8
|
+
module Dummy
|
9
|
+
class Application < Rails::Application
|
10
|
+
# Settings in config/environments/* take precedence over those specified here.
|
11
|
+
# Application configuration should go into files in config/initializers
|
12
|
+
# -- all .rb files in that directory are automatically loaded.
|
13
|
+
|
14
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
15
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
16
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
17
|
+
|
18
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
19
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
20
|
+
# config.i18n.default_locale = :de
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install sqlite3
|
3
|
+
#
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
+
# gem 'sqlite3'
|
6
|
+
#
|
7
|
+
default: &default
|
8
|
+
adapter: sqlite3
|
9
|
+
pool: 5
|
10
|
+
timeout: 5000
|
11
|
+
|
12
|
+
development:
|
13
|
+
<<: *default
|
14
|
+
database: db/development.sqlite3
|
15
|
+
|
16
|
+
# Warning: The database defined as "test" will be erased and
|
17
|
+
# re-generated from your development database when you run "rake".
|
18
|
+
# Do not set this db to the same as development or production.
|
19
|
+
test:
|
20
|
+
<<: *default
|
21
|
+
database: db/test.sqlite3
|
22
|
+
|
23
|
+
production:
|
24
|
+
<<: *default
|
25
|
+
database: db/production.sqlite3
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Rails.application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Do not eager load code on boot.
|
10
|
+
config.eager_load = false
|
11
|
+
|
12
|
+
# Show full error reports and disable caching.
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Don't care if the mailer can't send.
|
17
|
+
config.action_mailer.raise_delivery_errors = false
|
18
|
+
|
19
|
+
# Print deprecation notices to the Rails logger.
|
20
|
+
config.active_support.deprecation = :log
|
21
|
+
|
22
|
+
# Raise an error on page load if there are pending migrations.
|
23
|
+
config.active_record.migration_error = :page_load
|
24
|
+
|
25
|
+
# Debug mode disables concatenation and preprocessing of assets.
|
26
|
+
# This option may cause significant delays in view rendering with a large
|
27
|
+
# number of complex assets.
|
28
|
+
config.assets.debug = true
|
29
|
+
end
|