pagers 3.1.5 → 4.0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +28 -15
- data/Rakefile +1 -16
- data/app/views/pagers/_main.html.erb +1 -1
- data/lib/generators/pagers/install/install_generator.rb +13 -0
- data/lib/generators/pagers/install/templates/initializer.rb +7 -0
- data/lib/pagers.rb +8 -13
- data/lib/pagers/configuration.rb +7 -0
- data/lib/pagers/extensions/action_view/base.rb +48 -0
- data/lib/pagers/extensions/active_record/base.rb +43 -0
- data/lib/pagers/extensions/active_record/relation.rb +43 -0
- data/lib/pagers/railtie.rb +7 -3
- data/lib/pagers/version.rb +1 -1
- data/test/dummy/Rakefile +1 -2
- data/test/dummy/app/assets/javascripts/application.js +2 -2
- data/test/dummy/app/assets/stylesheets/application.css +6 -4
- data/test/dummy/app/controllers/products_controller.rb +8 -0
- data/test/dummy/app/models/product.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +9 -11
- data/test/dummy/app/views/products/index.html.erb +1 -0
- data/test/dummy/bin/bundle +1 -0
- data/test/dummy/bin/rails +2 -1
- data/test/dummy/bin/rake +1 -0
- data/test/dummy/bin/setup +30 -0
- data/test/dummy/config.ru +1 -1
- data/test/dummy/config/application.rb +3 -0
- data/test/dummy/config/boot.rb +1 -1
- data/test/dummy/config/database.yml +4 -22
- data/test/dummy/config/database.yml.travis +3 -0
- data/test/dummy/config/environment.rb +1 -1
- data/test/dummy/config/environments/development.rb +15 -3
- data/test/dummy/config/environments/production.rb +21 -26
- data/test/dummy/config/environments/test.rb +10 -12
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/mime_types.rb +1 -2
- data/test/dummy/config/initializers/pagers.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +1 -1
- data/test/dummy/config/routes.rb +1 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/db/migrate/20130820024335_create_products.rb +7 -0
- data/test/dummy/db/schema.rb +6 -4
- data/test/dummy/log/development.log +25 -0
- data/test/dummy/log/test.log +22127 -987
- data/test/dummy/public/404.html +58 -55
- data/test/dummy/public/422.html +58 -55
- data/test/dummy/public/500.html +57 -54
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/34/34l0xNON3WYrRP9HWkz5ZK9IQzIEVGYFn6VDMKiheeA.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/5L/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +2 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/OI/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +2 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/SG/SGNGr7AZfBE1q7ev2-YM1G-o0XAZ0pKqbsS3NvHtRcA.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/TO/TOCwj3wVkgMFleFRO8KMLE3Qq6FsXpCeZD56U1AEPEc.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/YJ/YJjzVvL4dd5E1S5fIpCphDLf9mEWeGfhO-ALTZpJ8-c.cache +0 -0
- data/test/dummy/tmp/cache/{sprockets/v3.0/4qi4l6mZwh9hUfWOWITw6FuJ15NRpPcIgJ22C20Yrhw.cache → assets/sprockets/v3.0/fG/fG_uaNK13wisQiji91xNsGecGxX9QhMCF2eSX_aR0G0.cache} +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/gb/gbunrAFVOHPwl2npUgKv_C3f_qiJnZDd9zG5-h3jrpo.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/hZ/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache +2 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/mv/mvqN6PphkrOOC8zbUEhpC_9E_4ybdO25MRy_gG6dq3Y.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/nm/nmcUZlKAIwyJ_35Nm9P8pukLeRX5aApP6NFj5MpNPgc.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/pE/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache +2 -0
- data/test/dummy/tmp/cache/{sprockets/v3.0/IXhyhrFX9OAFbL6na95F8HncYlwJm9_DdZx3OGTlvjk.cache → assets/sprockets/v3.0/sB/sB6xWxBmgzVC0Co9__ANYrE58lr4WPwiwFa9mswooWM.cache} +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/va/vaNrIny9hchHD9eIJxAicyYLC7qeV4PTh4Nh40_Y6Vg.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/xd/xdBKQyhEAlDIstGvXw945PWJoEWi23rKuY7elOcWqHc.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/yH/yHjEG5b89-DY37A9c_d90xiOarCQ4bJHa-i98W72DXI.cache +0 -0
- data/test/generator_test.rb +5 -5
- data/test/relation_test.rb +85 -0
- data/test/test_helper.rb +6 -13
- data/test/view_test.rb +47 -0
- metadata +75 -96
- data/lib/generators/pagers/install_generator.rb +0 -13
- data/lib/generators/pagers/templates/pagers.rb +0 -2
- data/lib/pagers/action_view/base.rb +0 -40
- data/lib/pagers/active_record/base.rb +0 -37
- data/lib/pagers/active_record/relation.rb +0 -41
- data/test/dummy/README.rdoc +0 -28
- data/test/dummy/app/controllers/pages_controller.rb +0 -7
- data/test/dummy/app/models/record.rb +0 -2
- data/test/dummy/app/views/pages/index.html.erb +0 -1
- data/test/dummy/config/initializers/secret_token.rb +0 -13
- data/test/dummy/db/migrate/20130820024335_create_records.rb +0 -9
- data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +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/dummy/tmp/cache/sprockets/v3.0/4CacREYU-WtfLMBbdP-dhQGvv5x5m64f08AyEfpJQOo.cache +0 -1
- data/test/dummy/tmp/cache/sprockets/v3.0/92EHsdop8I2qLLTnyIPHKsBjC79WjGLaG37jVJyQVhk.cache +0 -0
- data/test/dummy/tmp/cache/sprockets/v3.0/EWvcaZ9y1ATwOV77WPqF6MOVajQDzmhssysEljgt9Eo.cache +0 -0
- data/test/dummy/tmp/cache/sprockets/v3.0/Ko7VnYzTp2dC_WWnmGeCA4HQFz0DP4BhGt3lwlHhHi8.cache +0 -1
- data/test/dummy/tmp/cache/sprockets/v3.0/LhsrcVSJd1rOgmBlzouy8hNPVwxmPKoQ-Gas3gSxTkI.cache +0 -1
- data/test/dummy/tmp/cache/sprockets/v3.0/V69Dt-aUrVqv_nmsS1zbhdjuZiJYjFhnrydvD2K2GUM.cache +0 -0
- data/test/dummy/tmp/cache/sprockets/v3.0/_Ncty4f5wW4Cr2m5RgKKk4M1vjFREhRT4rNNa3xudJk.cache +0 -0
- data/test/dummy/tmp/cache/sprockets/v3.0/aN14MzsGXl0Y-OLjTiDPq1Q4JIyN7HL8WxyvnCmR15s.cache +0 -0
- data/test/dummy/tmp/cache/sprockets/v3.0/bK7xK7GDY9-6iymHURf47UyKHbhI_XkIoXheTZIkob8.cache +0 -1
- data/test/dummy/tmp/cache/sprockets/v3.0/hj8Ir9wcVSy1KYrnWu9bpD24vDhCG3tvt-nKbNxb1Wg.cache +0 -3
- data/test/dummy/tmp/cache/sprockets/v3.0/oCsZTGZyV4kH8Y4OeSDUdrwfkJFPzTODZjuBKZB8oGQ.cache +0 -2
- data/test/dummy/tmp/cache/sprockets/v3.0/pwlpdo053gu3Fg6oen1pnE9oV9ErbgrDW0VbKPLs098.cache +0 -0
- data/test/dummy/tmp/cache/sprockets/v3.0/q6BYa32YJF11eGVapO4ouNl6gayPIsARgMavlzZmoi0.cache +0 -3
- data/test/dummy/tmp/cache/sprockets/v3.0/x7KkTV3ibfIEysLB_ug5bfmnn2VLV_BldukPR3EoPBk.cache +0 -2
- data/test/empty_test.rb +0 -39
- data/test/first_test.rb +0 -43
- data/test/last_test.rb +0 -43
- data/test/middle_test.rb +0 -43
- data/test/padding_test.rb +0 -21
- data/test/route_test.rb +0 -69
@@ -1,41 +0,0 @@
|
|
1
|
-
module Pagers
|
2
|
-
module ActiveRecord
|
3
|
-
module Relation
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
|
6
|
-
def total_pages
|
7
|
-
@total_pages ||= [(total_count.to_f / page_length).ceil, 1].max
|
8
|
-
end
|
9
|
-
|
10
|
-
def previous_page
|
11
|
-
@previous_page ||= current_page > 1 ? (current_page - 1) : nil
|
12
|
-
end
|
13
|
-
|
14
|
-
def next_page
|
15
|
-
@next_page ||= current_page < total_pages ? (current_page + 1) : nil
|
16
|
-
end
|
17
|
-
|
18
|
-
def first_page
|
19
|
-
1
|
20
|
-
end
|
21
|
-
|
22
|
-
def last_page
|
23
|
-
total_pages
|
24
|
-
end
|
25
|
-
|
26
|
-
def out_of_bounds?
|
27
|
-
@out_of_bounds ||= (current_page > total_pages || current_page < first_page)
|
28
|
-
end
|
29
|
-
|
30
|
-
def total_count
|
31
|
-
@total_count ||= begin
|
32
|
-
r = except(:limit, :offset, :order, :reorder)
|
33
|
-
r = r.except(:includes) unless references_eager_loaded_tables?
|
34
|
-
r = r.count
|
35
|
-
(r.respond_to?(:count) ? r.count : r) - padding
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
data/test/dummy/README.rdoc
DELETED
@@ -1,28 +0,0 @@
|
|
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>.
|
@@ -1 +0,0 @@
|
|
1
|
-
<%= paginate @collection %>
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# Be sure to restart your server when you modify this file.
|
2
|
-
|
3
|
-
# Your secret key is used for verifying the integrity of signed cookies.
|
4
|
-
# If you change this key, all old signed cookies will become invalid!
|
5
|
-
|
6
|
-
# Make sure the secret is at least 30 characters and all random,
|
7
|
-
# no regular words or you'll be exposed to dictionary attacks.
|
8
|
-
# You can use `rake secret` to generate a secure secret key.
|
9
|
-
|
10
|
-
# Make sure your secret_key_base is kept private
|
11
|
-
# if you're sharing your code publicly.
|
12
|
-
Dummy::Application.config.secret_token = 'aa572dada91fb7649605f63cc687725e10ed30fddf9930432632a5fca89789fb3a83e42ef6d255b5b4c93805ccb5a3befbea0f4eaf60f48b3d95606be83fdd3f'
|
13
|
-
Dummy::Application.config.secret_key_base = 'aa572dada91fb7649605f63cc687725e10ed30fddf9930432632a5fca89789fb3a83e42ef6d255b5b4c93805ccb5a3befbea0f4eaf60f48b3d95606be83fdd3f'
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1 +0,0 @@
|
|
1
|
-
I"}app/assets/stylesheets/application.css?type=text/css&id=d2e009740cec455b7891368f3e4d273cf6b478179be05b73cd7460dc8a8660de:ET
|
Binary file
|
Binary file
|
@@ -1 +0,0 @@
|
|
1
|
-
I"�app/assets/stylesheets/application.css?type=text/css&pipeline=self&id=40aac95c2132021344e4916d11e7a17fb2b5d7aa567a9b62f432695e7b1708a4:ET
|
@@ -1 +0,0 @@
|
|
1
|
-
I"�app/assets/javascripts/application.js?type=application/javascript&id=c359a6fb8077c28dfb5cec53544a119b1f3457b50dcc59a1539b0902350ba3c3:ET
|
Binary file
|
Binary file
|
Binary file
|
@@ -1 +0,0 @@
|
|
1
|
-
I"�app/assets/javascripts/application.js?type=application/javascript&pipeline=self&id=51d4f3ec352352814ce198f3886c031fe06d5bf104322bc0bacef4305a1ba7d1:ET
|
@@ -1,2 +0,0 @@
|
|
1
|
-
[o:Set:
|
2
|
-
@hash{I"environment-version:ETTI"environment-paths;TTI"Lprocessors:type=application/javascript&file_type=application/javascript;TTI"8file-digest://app/assets/javascripts/application.js;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTI")file-digest://app/assets/javascripts;TT
|
Binary file
|
data/test/empty_test.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class EmptyTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
test 'total pages' do
|
6
|
-
assert_equal 1, relation.total_pages
|
7
|
-
end
|
8
|
-
|
9
|
-
test 'current page' do
|
10
|
-
assert_equal 1, relation.current_page
|
11
|
-
end
|
12
|
-
|
13
|
-
test 'first page' do
|
14
|
-
assert_equal 1, relation.first_page
|
15
|
-
end
|
16
|
-
|
17
|
-
test 'previous page' do
|
18
|
-
assert_nil relation.previous_page
|
19
|
-
end
|
20
|
-
|
21
|
-
test 'next page' do
|
22
|
-
assert_nil relation.next_page
|
23
|
-
end
|
24
|
-
|
25
|
-
test 'last page' do
|
26
|
-
assert_equal 1, relation.last_page
|
27
|
-
end
|
28
|
-
|
29
|
-
test 'out of bounds' do
|
30
|
-
assert !relation.out_of_bounds?
|
31
|
-
end
|
32
|
-
|
33
|
-
protected
|
34
|
-
|
35
|
-
def relation
|
36
|
-
@relation ||= Record.page(1, length: 2)
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
data/test/first_test.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class FirstTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
setup do
|
6
|
-
10.times.each { |index| Record.create }
|
7
|
-
end
|
8
|
-
|
9
|
-
test 'total pages' do
|
10
|
-
assert_equal 5, relation.total_pages
|
11
|
-
end
|
12
|
-
|
13
|
-
test 'current page' do
|
14
|
-
assert_equal 1, relation.current_page
|
15
|
-
end
|
16
|
-
|
17
|
-
test 'first page' do
|
18
|
-
assert_equal 1, relation.first_page
|
19
|
-
end
|
20
|
-
|
21
|
-
test 'previous page' do
|
22
|
-
assert_nil relation.previous_page
|
23
|
-
end
|
24
|
-
|
25
|
-
test 'next page' do
|
26
|
-
assert_equal 2, relation.next_page
|
27
|
-
end
|
28
|
-
|
29
|
-
test 'last page' do
|
30
|
-
assert_equal 5, relation.last_page
|
31
|
-
end
|
32
|
-
|
33
|
-
test 'out of bounds' do
|
34
|
-
assert !relation.out_of_bounds?
|
35
|
-
end
|
36
|
-
|
37
|
-
protected
|
38
|
-
|
39
|
-
def relation
|
40
|
-
@relation ||= Record.page(1, length: 2)
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
data/test/last_test.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class LastTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
setup do
|
6
|
-
10.times.each { |index| Record.create }
|
7
|
-
end
|
8
|
-
|
9
|
-
test 'total pages' do
|
10
|
-
assert_equal 5, relation.total_pages
|
11
|
-
end
|
12
|
-
|
13
|
-
test 'current page' do
|
14
|
-
assert_equal 5, relation.current_page
|
15
|
-
end
|
16
|
-
|
17
|
-
test 'first page' do
|
18
|
-
assert_equal 1, relation.first_page
|
19
|
-
end
|
20
|
-
|
21
|
-
test 'previous page' do
|
22
|
-
assert_equal 4, relation.previous_page
|
23
|
-
end
|
24
|
-
|
25
|
-
test 'next page' do
|
26
|
-
assert_nil relation.next_page
|
27
|
-
end
|
28
|
-
|
29
|
-
test 'last page' do
|
30
|
-
assert_equal 5, relation.last_page
|
31
|
-
end
|
32
|
-
|
33
|
-
test 'out of bounds' do
|
34
|
-
assert !relation.out_of_bounds?
|
35
|
-
end
|
36
|
-
|
37
|
-
protected
|
38
|
-
|
39
|
-
def relation
|
40
|
-
@relation ||= Record.page(5, length: 2)
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
data/test/middle_test.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class MiddleTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
setup do
|
6
|
-
10.times.each { |index| Record.create }
|
7
|
-
end
|
8
|
-
|
9
|
-
test 'total pages' do
|
10
|
-
assert_equal 5, relation.total_pages
|
11
|
-
end
|
12
|
-
|
13
|
-
test 'current page' do
|
14
|
-
assert_equal 3, relation.current_page
|
15
|
-
end
|
16
|
-
|
17
|
-
test 'first page' do
|
18
|
-
assert_equal 1, relation.first_page
|
19
|
-
end
|
20
|
-
|
21
|
-
test 'previous page' do
|
22
|
-
assert_equal 2, relation.previous_page
|
23
|
-
end
|
24
|
-
|
25
|
-
test 'next page' do
|
26
|
-
assert_equal 4, relation.next_page
|
27
|
-
end
|
28
|
-
|
29
|
-
test 'last page' do
|
30
|
-
assert_equal 5, relation.last_page
|
31
|
-
end
|
32
|
-
|
33
|
-
test 'out of bounds' do
|
34
|
-
assert !relation.out_of_bounds?
|
35
|
-
end
|
36
|
-
|
37
|
-
protected
|
38
|
-
|
39
|
-
def relation
|
40
|
-
@relation ||= Record.page(3, length: 2)
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
data/test/padding_test.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class PaddingTest < ActiveSupport::TestCase
|
4
|
-
|
5
|
-
test 'total pages with padding' do
|
6
|
-
19.times.each { |index| Record.create }
|
7
|
-
|
8
|
-
relation = Record.page(1, length: 15, padding: 4)
|
9
|
-
assert_equal 15, relation.size
|
10
|
-
assert_equal 1, relation.total_pages
|
11
|
-
|
12
|
-
relation = Record.page(2, length: 15, padding: 4)
|
13
|
-
assert_equal 0, relation.size
|
14
|
-
assert_equal 1, relation.total_pages
|
15
|
-
|
16
|
-
relation = Record.page(3, length: 15, padding: 4)
|
17
|
-
assert_equal 0, relation.size
|
18
|
-
assert_equal 1, relation.total_pages
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
data/test/route_test.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class RouteTest < ActionDispatch::IntegrationTest
|
4
|
-
|
5
|
-
test 'query param' do
|
6
|
-
Rails.application.routes.draw do
|
7
|
-
get '/' => 'pages#index'
|
8
|
-
end
|
9
|
-
|
10
|
-
10.times.each { Record.create }
|
11
|
-
get '/'
|
12
|
-
if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
|
13
|
-
assert_select 'li.current a[href="/?page=1"]:contains(1)'
|
14
|
-
else
|
15
|
-
assert_select 'li.current a[href="/?page=1"]', '1'
|
16
|
-
end
|
17
|
-
get '/?page=2'
|
18
|
-
if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
|
19
|
-
assert_select 'li.current a[href="/?page=2"]:contains(2)'
|
20
|
-
else
|
21
|
-
assert_select 'li.current a[href="/?page=2"]', '2'
|
22
|
-
end
|
23
|
-
get '/?dummy='
|
24
|
-
if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
|
25
|
-
assert_select 'li.current a[href="/?dummy=&page=1"]:contains(1)'
|
26
|
-
else
|
27
|
-
assert_select 'li.current a[href="/?dummy=&page=1"]', '1'
|
28
|
-
end
|
29
|
-
get '/?dummy=&page=2'
|
30
|
-
if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
|
31
|
-
assert_select 'li.current a[href="/?dummy=&page=2"]:contains(2)'
|
32
|
-
else
|
33
|
-
assert_select 'li.current a[href="/?dummy=&page=2"]', '2'
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
test 'route param' do
|
38
|
-
Rails.application.routes.draw do
|
39
|
-
get '(:page)' => 'pages#index'
|
40
|
-
end
|
41
|
-
|
42
|
-
10.times.each { Record.create }
|
43
|
-
get '/'
|
44
|
-
if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
|
45
|
-
assert_select 'li.current a[href="/1"]:contains(1)'
|
46
|
-
else
|
47
|
-
assert_select 'li.current a[href="/1"]', '1'
|
48
|
-
end
|
49
|
-
get '/2'
|
50
|
-
if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
|
51
|
-
assert_select 'li.current a[href="/2"]:contains(2)'
|
52
|
-
else
|
53
|
-
assert_select 'li.current a[href="/2"]', '2'
|
54
|
-
end
|
55
|
-
get '/?dummy='
|
56
|
-
if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
|
57
|
-
assert_select 'li.current a[href="/1?dummy="]:contains(1)'
|
58
|
-
else
|
59
|
-
assert_select 'li.current a[href="/1?dummy="]', '1'
|
60
|
-
end
|
61
|
-
get '/2?dummy='
|
62
|
-
if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
|
63
|
-
assert_select 'li.current a[href="/2?dummy="]:contains(2)'
|
64
|
-
else
|
65
|
-
assert_select 'li.current a[href="/2?dummy="]', '2'
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
end
|