will_paginate 2.3.15 → 2.3.16
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of will_paginate might be problematic. Click here for more details.
- data/CHANGELOG.rdoc +22 -0
- data/README.md +53 -0
- data/Rakefile +19 -44
- data/lib/will_paginate.rb +13 -6
- data/lib/will_paginate/array.rb +7 -7
- data/lib/will_paginate/collection.rb +22 -8
- data/lib/will_paginate/finder.rb +2 -2
- data/lib/will_paginate/i18n.rb +29 -0
- data/lib/will_paginate/locale/en.yml +33 -0
- data/lib/will_paginate/per_page.rb +27 -0
- data/lib/will_paginate/version.rb +1 -1
- data/lib/will_paginate/view_helpers.rb +76 -33
- data/test/ci.rb +56 -0
- data/test/collection_test.rb +19 -2
- data/test/console +4 -4
- data/test/database.yml +4 -10
- data/test/finder_test.rb +24 -0
- data/test/fixtures/developer.rb +1 -1
- data/test/gemfiles/Gemfile.1.2 +13 -0
- data/test/gemfiles/Gemfile.1.2.lock +39 -0
- data/test/gemfiles/Gemfile.2.0 +16 -0
- data/test/gemfiles/Gemfile.2.0.lock +28 -0
- data/test/gemfiles/Gemfile.2.1 +16 -0
- data/test/gemfiles/Gemfile.2.1.lock +28 -0
- data/test/gemfiles/Gemfile.2.2 +16 -0
- data/test/gemfiles/Gemfile.2.2.lock +28 -0
- data/test/helper.rb +7 -10
- data/test/lib/activerecord_test_case.rb +7 -12
- data/test/lib/activerecord_test_connector.rb +14 -4
- data/test/lib/load_fixtures.rb +2 -1
- data/test/lib/view_test_process.rb +7 -0
- data/test/view_test.rb +5 -5
- metadata +22 -25
- data/README.rdoc +0 -107
- data/test/boot.rb +0 -21
- data/test/tasks.rake +0 -59
data/test/ci.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
databases = %w[ sqlite3 mysql postgres ]
|
3
|
+
# skip mysql on 1.8.6 (doesn't work for unknown reason)
|
4
|
+
run_mysql = !(ENV['TRAVIS'] && RUBY_VERSION == '1.8.6')
|
5
|
+
|
6
|
+
def announce(name, msg)
|
7
|
+
puts "\n\e[1;33m[#{name}] #{msg}\e[m\n"
|
8
|
+
end
|
9
|
+
|
10
|
+
def rails_version(gemfile)
|
11
|
+
gemfile =~ /\d[\d.]*$/ ? $& : '2.3'
|
12
|
+
end
|
13
|
+
|
14
|
+
def system(*args)
|
15
|
+
puts "$ #{args.join(' ')}"
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
if ENV['TRAVIS']
|
20
|
+
if run_mysql
|
21
|
+
system "mysql -e 'create database will_paginate;' >/dev/null"
|
22
|
+
abort "failed to create mysql database" unless $?.success?
|
23
|
+
end
|
24
|
+
system "psql -c 'create database will_paginate;' -U postgres >/dev/null"
|
25
|
+
abort "failed to create postgres database" unless $?.success?
|
26
|
+
end
|
27
|
+
|
28
|
+
gemfiles = ['Gemfile']
|
29
|
+
gemfiles.concat Dir['test/gemfiles/*'].reject { |f| f.include? '.lock' }.sort.reverse
|
30
|
+
|
31
|
+
ruby19 = RUBY_VERSION > '1.9'
|
32
|
+
ruby19_gemfiles = gemfiles.first
|
33
|
+
|
34
|
+
bundler_options = ENV['TRAVIS'] ? "--path #{Dir.pwd}/vendor/bundle" : ''
|
35
|
+
|
36
|
+
failed = false
|
37
|
+
|
38
|
+
gemfiles.each do |gemfile|
|
39
|
+
next if ruby19 and !ruby19_gemfiles.include? gemfile
|
40
|
+
version = rails_version(gemfile)
|
41
|
+
ENV['BUNDLE_GEMFILE'] = gemfile
|
42
|
+
skip_install = gemfile == gemfiles.first
|
43
|
+
if skip_install or system %(bundle install #{bundler_options})
|
44
|
+
for db in databases
|
45
|
+
next if 'mysql' == db and !run_mysql
|
46
|
+
announce "Rails #{version}", "with #{db}"
|
47
|
+
ENV['DB'] = db
|
48
|
+
failed = true unless system %(bundle exec rake)
|
49
|
+
end
|
50
|
+
else
|
51
|
+
# bundle install failed
|
52
|
+
failed = true
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
exit 1 if failed
|
data/test/collection_test.rb
CHANGED
@@ -119,8 +119,9 @@ class ArrayPaginationTest < Test::Unit::TestCase
|
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
|
-
def
|
123
|
-
assert_raise(
|
122
|
+
def test_invalid_offset
|
123
|
+
error = assert_raise(WillPaginate::InvalidPage) { create(307445734561825862, 30) }
|
124
|
+
assert_equal "invalid offset: 9223372036854775830", error.message
|
124
125
|
end
|
125
126
|
|
126
127
|
def test_page_count_was_removed
|
@@ -128,6 +129,22 @@ class ArrayPaginationTest < Test::Unit::TestCase
|
|
128
129
|
# It's `total_pages` now.
|
129
130
|
end
|
130
131
|
|
132
|
+
def test_inherits_global_per_page
|
133
|
+
col = WillPaginate::Collection.new(1)
|
134
|
+
assert_equal 30, col.per_page
|
135
|
+
|
136
|
+
WillPaginate.per_page = 12
|
137
|
+
begin
|
138
|
+
col = WillPaginate::Collection.new(1)
|
139
|
+
assert_equal 12, col.per_page
|
140
|
+
|
141
|
+
col = ('a'..'z').to_a.paginate(:page => 1)
|
142
|
+
assert_equal 12, col.per_page
|
143
|
+
ensure
|
144
|
+
WillPaginate.per_page = 30
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
131
148
|
private
|
132
149
|
def create(page = 2, limit = 5, total = nil, &block)
|
133
150
|
if block_given?
|
data/test/console
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
3
|
-
libs = []
|
4
3
|
|
5
|
-
|
6
|
-
|
4
|
+
opts = %w[ --simple-prompt ]
|
5
|
+
opts << '-rirb/completion'
|
6
|
+
opts << '-rlib/load_fixtures'
|
7
7
|
|
8
|
-
exec
|
8
|
+
exec irb, '-Ilib:test', *opts
|
data/test/database.yml
CHANGED
@@ -3,20 +3,14 @@ sqlite3:
|
|
3
3
|
adapter: sqlite3
|
4
4
|
timeout: 500
|
5
5
|
|
6
|
-
sqlite2:
|
7
|
-
database: ":memory:"
|
8
|
-
adapter: sqlite2
|
9
|
-
|
10
6
|
mysql:
|
11
7
|
adapter: mysql
|
12
|
-
|
13
|
-
|
8
|
+
database: will_paginate
|
9
|
+
username:
|
14
10
|
encoding: utf8
|
15
|
-
database: will_paginate_unittest
|
16
11
|
|
17
12
|
postgres:
|
18
13
|
adapter: postgresql
|
19
|
-
|
20
|
-
|
21
|
-
database: will_paginate_unittest
|
14
|
+
database: will_paginate
|
15
|
+
username: postgres
|
22
16
|
min_messages: warning
|
data/test/finder_test.rb
CHANGED
@@ -27,6 +27,27 @@ class FinderTest < ActiveRecordTestCase
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
+
def test_per_page_setting
|
31
|
+
assert_equal 30, Topic.per_page
|
32
|
+
Topic.per_page = 12
|
33
|
+
begin
|
34
|
+
assert_equal 12, Topic.per_page
|
35
|
+
ensure
|
36
|
+
Topic.per_page = 30
|
37
|
+
end
|
38
|
+
assert_equal 10, Developer.per_page
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_per_page_inheritance
|
42
|
+
subclass = Class.new(Topic)
|
43
|
+
assert_equal 30, subclass.per_page
|
44
|
+
subclass.per_page = 12
|
45
|
+
assert_equal 12, subclass.per_page
|
46
|
+
assert_equal 30, Topic.per_page
|
47
|
+
sub_subclass = Class.new(subclass)
|
48
|
+
assert_equal 12, sub_subclass.per_page
|
49
|
+
end
|
50
|
+
|
30
51
|
def test_parameter_api
|
31
52
|
# :page parameter in options is required!
|
32
53
|
assert_raise(ArgumentError){ Topic.paginate }
|
@@ -246,6 +267,8 @@ class FinderTest < ActiveRecordTestCase
|
|
246
267
|
assert_equal 2, entries.total_entries
|
247
268
|
end
|
248
269
|
|
270
|
+
# fat chance I'll ever get to debugging and fixing this
|
271
|
+
unless '1.8.7' == RUBY_VERSION and ActiveRecord::VERSION::STRING < '2.2'
|
249
272
|
def test_paginate_in_named_scope_on_habtm_association
|
250
273
|
project = projects(:active_record)
|
251
274
|
assert_queries(2) do
|
@@ -255,6 +278,7 @@ class FinderTest < ActiveRecordTestCase
|
|
255
278
|
assert_equal 1, entries.total_entries, 'only one developer should be found'
|
256
279
|
end
|
257
280
|
end
|
281
|
+
end
|
258
282
|
|
259
283
|
def test_paginate_in_named_scope_on_hmt_association
|
260
284
|
project = projects(:active_record)
|
data/test/fixtures/developer.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
gem 'rails', '~> 1.2.6'
|
4
|
+
|
5
|
+
gem 'rake', '~> 0.8.7'
|
6
|
+
gem 'mocha', '0.9.2'
|
7
|
+
gem 'sqlite3-ruby', '1.3.1'
|
8
|
+
gem 'mysql', :group => :mysql
|
9
|
+
|
10
|
+
group :pg do
|
11
|
+
gem 'postgres', :platforms => :ruby_18
|
12
|
+
gem 'pg', :platforms => :ruby_19
|
13
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
actionmailer (1.3.6)
|
5
|
+
actionpack (= 1.13.6)
|
6
|
+
actionpack (1.13.6)
|
7
|
+
activesupport (= 1.4.4)
|
8
|
+
actionwebservice (1.2.6)
|
9
|
+
actionpack (= 1.13.6)
|
10
|
+
activerecord (= 1.15.6)
|
11
|
+
activerecord (1.15.6)
|
12
|
+
activesupport (= 1.4.4)
|
13
|
+
activesupport (1.4.4)
|
14
|
+
mocha (0.9.2)
|
15
|
+
rake
|
16
|
+
mysql (2.8.1)
|
17
|
+
pg (0.11.0)
|
18
|
+
postgres (0.7.9.2008.01.28)
|
19
|
+
rails (1.2.6)
|
20
|
+
actionmailer (= 1.3.6)
|
21
|
+
actionpack (= 1.13.6)
|
22
|
+
actionwebservice (= 1.2.6)
|
23
|
+
activerecord (= 1.15.6)
|
24
|
+
activesupport (= 1.4.4)
|
25
|
+
rake (>= 0.7.2)
|
26
|
+
rake (0.8.7)
|
27
|
+
sqlite3-ruby (1.3.1)
|
28
|
+
|
29
|
+
PLATFORMS
|
30
|
+
ruby
|
31
|
+
|
32
|
+
DEPENDENCIES
|
33
|
+
mocha (= 0.9.2)
|
34
|
+
mysql
|
35
|
+
pg
|
36
|
+
postgres
|
37
|
+
rails (~> 1.2.6)
|
38
|
+
rake (~> 0.8.7)
|
39
|
+
sqlite3-ruby (= 1.3.1)
|
@@ -0,0 +1,16 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
rails_version = '~> 2.0.4'
|
4
|
+
|
5
|
+
gem 'actionpack', rails_version
|
6
|
+
gem 'activerecord', rails_version
|
7
|
+
|
8
|
+
gem 'rake', '~> 0.8.7'
|
9
|
+
gem 'mocha', '0.9.2'
|
10
|
+
gem 'sqlite3-ruby', '1.3.1'
|
11
|
+
gem 'mysql', :group => :mysql
|
12
|
+
|
13
|
+
group :pg do
|
14
|
+
gem 'postgres', :platforms => :ruby_18
|
15
|
+
gem 'pg', :platforms => :ruby_19
|
16
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
actionpack (2.0.5)
|
5
|
+
activesupport (= 2.0.5)
|
6
|
+
activerecord (2.0.5)
|
7
|
+
activesupport (= 2.0.5)
|
8
|
+
activesupport (2.0.5)
|
9
|
+
mocha (0.9.2)
|
10
|
+
rake
|
11
|
+
mysql (2.8.1)
|
12
|
+
pg (0.11.0)
|
13
|
+
postgres (0.7.9.2008.01.28)
|
14
|
+
rake (0.8.7)
|
15
|
+
sqlite3-ruby (1.3.1)
|
16
|
+
|
17
|
+
PLATFORMS
|
18
|
+
ruby
|
19
|
+
|
20
|
+
DEPENDENCIES
|
21
|
+
actionpack (~> 2.0.4)
|
22
|
+
activerecord (~> 2.0.4)
|
23
|
+
mocha (= 0.9.2)
|
24
|
+
mysql
|
25
|
+
pg
|
26
|
+
postgres
|
27
|
+
rake (~> 0.8.7)
|
28
|
+
sqlite3-ruby (= 1.3.1)
|
@@ -0,0 +1,16 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
rails_version = '~> 2.1.0'
|
4
|
+
|
5
|
+
gem 'actionpack', rails_version
|
6
|
+
gem 'activerecord', rails_version
|
7
|
+
|
8
|
+
gem 'rake', '~> 0.8.7'
|
9
|
+
gem 'mocha', '0.9.2'
|
10
|
+
gem 'sqlite3-ruby', '1.3.1'
|
11
|
+
gem 'mysql', :group => :mysql
|
12
|
+
|
13
|
+
group :pg do
|
14
|
+
gem 'postgres', :platforms => :ruby_18
|
15
|
+
gem 'pg', :platforms => :ruby_19
|
16
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
actionpack (2.1.2)
|
5
|
+
activesupport (= 2.1.2)
|
6
|
+
activerecord (2.1.2)
|
7
|
+
activesupport (= 2.1.2)
|
8
|
+
activesupport (2.1.2)
|
9
|
+
mocha (0.9.2)
|
10
|
+
rake
|
11
|
+
mysql (2.8.1)
|
12
|
+
pg (0.11.0)
|
13
|
+
postgres (0.7.9.2008.01.28)
|
14
|
+
rake (0.8.7)
|
15
|
+
sqlite3-ruby (1.3.1)
|
16
|
+
|
17
|
+
PLATFORMS
|
18
|
+
ruby
|
19
|
+
|
20
|
+
DEPENDENCIES
|
21
|
+
actionpack (~> 2.1.0)
|
22
|
+
activerecord (~> 2.1.0)
|
23
|
+
mocha (= 0.9.2)
|
24
|
+
mysql
|
25
|
+
pg
|
26
|
+
postgres
|
27
|
+
rake (~> 0.8.7)
|
28
|
+
sqlite3-ruby (= 1.3.1)
|
@@ -0,0 +1,16 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
rails_version = '~> 2.2.2'
|
4
|
+
|
5
|
+
gem 'actionpack', rails_version
|
6
|
+
gem 'activerecord', rails_version
|
7
|
+
|
8
|
+
gem 'rake', '~> 0.8.7'
|
9
|
+
gem 'mocha', '0.9.2'
|
10
|
+
gem 'sqlite3-ruby', '1.3.1'
|
11
|
+
gem 'mysql', :group => :mysql
|
12
|
+
|
13
|
+
group :pg do
|
14
|
+
gem 'postgres', :platforms => :ruby_18
|
15
|
+
gem 'pg', :platforms => :ruby_19
|
16
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
actionpack (2.2.3)
|
5
|
+
activesupport (= 2.2.3)
|
6
|
+
activerecord (2.2.3)
|
7
|
+
activesupport (= 2.2.3)
|
8
|
+
activesupport (2.2.3)
|
9
|
+
mocha (0.9.2)
|
10
|
+
rake
|
11
|
+
mysql (2.8.1)
|
12
|
+
pg (0.11.0)
|
13
|
+
postgres (0.7.9.2008.01.28)
|
14
|
+
rake (0.8.7)
|
15
|
+
sqlite3-ruby (1.3.1)
|
16
|
+
|
17
|
+
PLATFORMS
|
18
|
+
ruby
|
19
|
+
|
20
|
+
DEPENDENCIES
|
21
|
+
actionpack (~> 2.2.2)
|
22
|
+
activerecord (~> 2.2.2)
|
23
|
+
mocha (= 0.9.2)
|
24
|
+
mysql
|
25
|
+
pg
|
26
|
+
postgres
|
27
|
+
rake (~> 0.8.7)
|
28
|
+
sqlite3-ruby (= 1.3.1)
|
data/test/helper.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'test/unit'
|
2
|
-
require '
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
require 'mocha'
|
3
|
+
require 'will_paginate'
|
4
|
+
begin
|
5
|
+
require 'ruby-debug'
|
6
|
+
rescue LoadError
|
7
|
+
# no debuggging
|
8
|
+
end
|
8
9
|
|
9
10
|
class Test::Unit::TestCase
|
10
11
|
protected
|
@@ -29,9 +30,5 @@ end
|
|
29
30
|
|
30
31
|
# Wrap tests that use Mocha and skip if unavailable.
|
31
32
|
def uses_mocha(test_name)
|
32
|
-
require 'mocha'
|
33
|
-
rescue LoadError
|
34
|
-
$stderr.puts "Skipping #{test_name} tests. `gem install mocha` and try again."
|
35
|
-
else
|
36
33
|
yield
|
37
34
|
end
|
@@ -8,19 +8,9 @@ class ActiveRecordTestCase < Test::Unit::TestCase
|
|
8
8
|
if defined?(ActiveRecord::TestFixtures)
|
9
9
|
include ActiveRecord::TestFixtures
|
10
10
|
end
|
11
|
-
# Set our fixture path
|
12
|
-
if ActiveRecordTestConnector.able_to_connect
|
13
|
-
self.fixture_path = File.join(File.dirname(__FILE__), '..', 'fixtures')
|
14
|
-
self.use_transactional_fixtures = true
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.fixtures(*args)
|
18
|
-
super if ActiveRecordTestConnector.connected
|
19
|
-
end
|
20
11
|
|
21
|
-
|
22
|
-
|
23
|
-
end
|
12
|
+
self.fixture_path = File.join(File.dirname(__FILE__), '..', 'fixtures')
|
13
|
+
self.use_transactional_fixtures = true
|
24
14
|
|
25
15
|
# Default so Test::Unit::TestCase doesn't complain
|
26
16
|
def test_truth
|
@@ -35,9 +25,14 @@ class ActiveRecordTestCase < Test::Unit::TestCase
|
|
35
25
|
assert_equal num, $query_count, "#{$query_count} instead of #{num} queries were executed."
|
36
26
|
end
|
37
27
|
|
28
|
+
def method_name
|
29
|
+
'moo' # hack
|
30
|
+
end
|
31
|
+
|
38
32
|
def assert_no_queries(&block)
|
39
33
|
assert_queries(0, &block)
|
40
34
|
end
|
41
35
|
end
|
42
36
|
|
43
37
|
ActiveRecordTestConnector.setup
|
38
|
+
abort unless ActiveRecordTestConnector.able_to_connect
|