will_paginate 2.3.17 → 3.0.pre
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.
Potentially problematic release.
This version of will_paginate might be problematic. Click here for more details.
- data/CHANGELOG.rdoc +24 -80
- data/LICENSE +1 -1
- data/README.rdoc +125 -0
- data/Rakefile +26 -22
- data/lib/will_paginate.rb +10 -84
- data/lib/will_paginate/array.rb +25 -8
- data/lib/will_paginate/collection.rb +15 -28
- data/lib/will_paginate/core_ext.rb +26 -0
- data/lib/will_paginate/deprecation.rb +50 -0
- data/lib/will_paginate/finders.rb +9 -0
- data/lib/will_paginate/finders/active_record.rb +158 -0
- data/lib/will_paginate/finders/active_resource.rb +51 -0
- data/lib/will_paginate/finders/base.rb +112 -0
- data/lib/will_paginate/finders/data_mapper.rb +30 -0
- data/lib/will_paginate/finders/sequel.rb +23 -0
- data/lib/will_paginate/railtie.rb +26 -0
- data/lib/will_paginate/version.rb +5 -5
- data/lib/will_paginate/view_helpers.rb +25 -436
- data/lib/will_paginate/view_helpers/action_view.rb +142 -0
- data/lib/will_paginate/view_helpers/base.rb +126 -0
- data/lib/will_paginate/view_helpers/link_renderer.rb +130 -0
- data/lib/will_paginate/view_helpers/link_renderer_base.rb +83 -0
- data/lib/will_paginate/view_helpers/merb.rb +13 -0
- data/spec/collection_spec.rb +147 -0
- data/spec/console +8 -0
- data/spec/console_fixtures.rb +8 -0
- data/spec/database.yml +22 -0
- data/spec/finders/active_record_spec.rb +377 -0
- data/spec/finders/active_resource_spec.rb +52 -0
- data/spec/finders/activerecord_test_connector.rb +114 -0
- data/spec/finders/data_mapper_spec.rb +62 -0
- data/spec/finders/data_mapper_test_connector.rb +20 -0
- data/spec/finders/sequel_spec.rb +53 -0
- data/spec/finders/sequel_test_connector.rb +9 -0
- data/spec/finders_spec.rb +76 -0
- data/{test → spec}/fixtures/admin.rb +0 -0
- data/{test → spec}/fixtures/developer.rb +2 -3
- data/{test → spec}/fixtures/developers_projects.yml +0 -0
- data/{test → spec}/fixtures/project.rb +2 -6
- data/{test → spec}/fixtures/projects.yml +1 -1
- data/{test → spec}/fixtures/replies.yml +0 -0
- data/{test → spec}/fixtures/reply.rb +1 -1
- data/{test → spec}/fixtures/schema.rb +0 -0
- data/spec/fixtures/topic.rb +7 -0
- data/{test → spec}/fixtures/topics.yml +0 -0
- data/{test → spec}/fixtures/user.rb +0 -0
- data/{test → spec}/fixtures/users.yml +0 -0
- data/spec/rcov.opts +2 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +74 -0
- data/spec/tasks.rake +60 -0
- data/spec/view_helpers/action_view_spec.rb +345 -0
- data/spec/view_helpers/base_spec.rb +64 -0
- data/spec/view_helpers/link_renderer_base_spec.rb +84 -0
- data/spec/view_helpers/view_example_group.rb +103 -0
- metadata +60 -65
- data/README.md +0 -53
- data/lib/will_paginate/finder.rb +0 -269
- data/lib/will_paginate/i18n.rb +0 -29
- data/lib/will_paginate/locale/en.yml +0 -33
- data/lib/will_paginate/named_scope.rb +0 -170
- data/lib/will_paginate/named_scope_patch.rb +0 -37
- data/lib/will_paginate/per_page.rb +0 -27
- data/test/ci.rb +0 -60
- data/test/collection_test.rb +0 -160
- data/test/console +0 -8
- data/test/database.yml +0 -16
- data/test/finder_test.rb +0 -527
- data/test/fixtures/topic.rb +0 -12
- data/test/gemfiles/Gemfile.1.2 +0 -13
- data/test/gemfiles/Gemfile.1.2.lock +0 -39
- data/test/gemfiles/Gemfile.2.0 +0 -16
- data/test/gemfiles/Gemfile.2.0.lock +0 -28
- data/test/gemfiles/Gemfile.2.1 +0 -16
- data/test/gemfiles/Gemfile.2.1.lock +0 -28
- data/test/gemfiles/Gemfile.2.2 +0 -16
- data/test/gemfiles/Gemfile.2.2.lock +0 -28
- data/test/helper.rb +0 -34
- data/test/lib/activerecord_test_case.rb +0 -38
- data/test/lib/activerecord_test_connector.rb +0 -86
- data/test/lib/load_fixtures.rb +0 -12
- data/test/lib/view_test_process.rb +0 -186
- data/test/view_test.rb +0 -380
data/test/fixtures/topic.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
class Topic < ActiveRecord::Base
|
2
|
-
has_many :replies, :dependent => :destroy, :order => 'replies.created_at DESC'
|
3
|
-
belongs_to :project
|
4
|
-
|
5
|
-
named_scope :mentions_activerecord, :conditions => ['topics.title LIKE ?', '%ActiveRecord%']
|
6
|
-
|
7
|
-
named_scope :with_replies_starting_with, lambda { |text|
|
8
|
-
{ :conditions => "replies.content LIKE '#{text}%' ", :include => :replies }
|
9
|
-
}
|
10
|
-
|
11
|
-
def self.paginate_by_definition_in_class; end
|
12
|
-
end
|
data/test/gemfiles/Gemfile.1.2
DELETED
@@ -1,13 +0,0 @@
|
|
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
|
@@ -1,39 +0,0 @@
|
|
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)
|
data/test/gemfiles/Gemfile.2.0
DELETED
@@ -1,16 +0,0 @@
|
|
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
|
@@ -1,28 +0,0 @@
|
|
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)
|
data/test/gemfiles/Gemfile.2.1
DELETED
@@ -1,16 +0,0 @@
|
|
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
|
@@ -1,28 +0,0 @@
|
|
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)
|
data/test/gemfiles/Gemfile.2.2
DELETED
@@ -1,16 +0,0 @@
|
|
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
|
@@ -1,28 +0,0 @@
|
|
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
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'mocha'
|
3
|
-
require 'will_paginate'
|
4
|
-
begin
|
5
|
-
require 'ruby-debug'
|
6
|
-
rescue LoadError
|
7
|
-
# no debuggging
|
8
|
-
end
|
9
|
-
|
10
|
-
class Test::Unit::TestCase
|
11
|
-
protected
|
12
|
-
def assert_respond_to_all object, methods
|
13
|
-
methods.each do |method|
|
14
|
-
[method.to_s, method.to_sym].each { |m| assert_respond_to object, m }
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def collect_deprecations
|
19
|
-
old_behavior = WillPaginate::Deprecation.behavior
|
20
|
-
deprecations = []
|
21
|
-
WillPaginate::Deprecation.behavior = Proc.new do |message, callstack|
|
22
|
-
deprecations << message
|
23
|
-
end
|
24
|
-
result = yield
|
25
|
-
[result, deprecations]
|
26
|
-
ensure
|
27
|
-
WillPaginate::Deprecation.behavior = old_behavior
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# Wrap tests that use Mocha and skip if unavailable.
|
32
|
-
def uses_mocha(test_name)
|
33
|
-
yield
|
34
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'lib/activerecord_test_connector'
|
2
|
-
|
3
|
-
class ActiveRecordTestCase < Test::Unit::TestCase
|
4
|
-
if defined?(ActiveSupport::Testing::SetupAndTeardown)
|
5
|
-
include ActiveSupport::Testing::SetupAndTeardown
|
6
|
-
end
|
7
|
-
|
8
|
-
if defined?(ActiveRecord::TestFixtures)
|
9
|
-
include ActiveRecord::TestFixtures
|
10
|
-
end
|
11
|
-
|
12
|
-
self.fixture_path = File.join(File.dirname(__FILE__), '..', 'fixtures')
|
13
|
-
self.use_transactional_fixtures = true
|
14
|
-
|
15
|
-
# Default so Test::Unit::TestCase doesn't complain
|
16
|
-
def test_truth
|
17
|
-
end
|
18
|
-
|
19
|
-
protected
|
20
|
-
|
21
|
-
def assert_queries(num = 1)
|
22
|
-
$query_count = 0
|
23
|
-
yield
|
24
|
-
ensure
|
25
|
-
assert_equal num, $query_count, "#{$query_count} instead of #{num} queries were executed."
|
26
|
-
end
|
27
|
-
|
28
|
-
def method_name
|
29
|
-
'moo' # hack
|
30
|
-
end
|
31
|
-
|
32
|
-
def assert_no_queries(&block)
|
33
|
-
assert_queries(0, &block)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
ActiveRecordTestConnector.setup
|
38
|
-
abort unless ActiveRecordTestConnector.able_to_connect
|
@@ -1,86 +0,0 @@
|
|
1
|
-
require 'active_record'
|
2
|
-
require 'active_record/version'
|
3
|
-
require 'active_record/fixtures'
|
4
|
-
|
5
|
-
# prevent psych kicking in on 1.9 and interpreting
|
6
|
-
# local timestamps in fixtures as UTC
|
7
|
-
YAML::ENGINE.yamler = 'syck' if defined? YAML::ENGINE
|
8
|
-
|
9
|
-
class ActiveRecordTestConnector
|
10
|
-
cattr_accessor :able_to_connect
|
11
|
-
cattr_accessor :connected
|
12
|
-
|
13
|
-
FIXTURES_PATH = File.join(File.dirname(__FILE__), '..', 'fixtures')
|
14
|
-
|
15
|
-
# Set our defaults
|
16
|
-
self.connected = false
|
17
|
-
self.able_to_connect = true
|
18
|
-
|
19
|
-
def self.setup
|
20
|
-
unless self.connected || !self.able_to_connect
|
21
|
-
setup_connection
|
22
|
-
load_schema
|
23
|
-
add_load_path FIXTURES_PATH
|
24
|
-
self.connected = true
|
25
|
-
end
|
26
|
-
rescue Exception => e # errors from ActiveRecord setup
|
27
|
-
$stderr.puts "\nSkipping ActiveRecord tests: #{e}\n\n"
|
28
|
-
self.able_to_connect = false
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
def self.add_load_path(path)
|
34
|
-
dep = defined?(ActiveSupport::Dependencies) ? ActiveSupport::Dependencies : ::Dependencies
|
35
|
-
autoload_paths = dep.respond_to?(:autoload_paths) ? dep.autoload_paths : dep.load_paths
|
36
|
-
autoload_paths.unshift path
|
37
|
-
end
|
38
|
-
|
39
|
-
def self.setup_connection
|
40
|
-
db = ENV['DB'].blank?? 'sqlite3' : ENV['DB']
|
41
|
-
|
42
|
-
configurations = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'database.yml'))
|
43
|
-
raise "no configuration for '#{db}'" unless configurations.key? db
|
44
|
-
configuration = configurations[db]
|
45
|
-
|
46
|
-
ActiveRecord::Base.logger = Logger.new(STDOUT) if $0 == 'irb'
|
47
|
-
puts "using #{configuration['adapter']} adapter" unless ENV['DB'].blank?
|
48
|
-
|
49
|
-
ActiveRecord::Base.establish_connection(configuration)
|
50
|
-
ActiveRecord::Base.configurations = { db => configuration }
|
51
|
-
ActiveRecord::Base.default_timezone = :local if ActiveRecord::Base.respond_to? :default_timezone
|
52
|
-
prepare ActiveRecord::Base.connection
|
53
|
-
|
54
|
-
unless Object.const_defined?(:QUOTED_TYPE)
|
55
|
-
Object.send :const_set, :QUOTED_TYPE, ActiveRecord::Base.connection.quote_column_name('type')
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def self.load_schema
|
60
|
-
ActiveRecord::Base.silence do
|
61
|
-
ActiveRecord::Migration.verbose = false
|
62
|
-
load File.join(FIXTURES_PATH, 'schema.rb')
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def self.prepare(conn)
|
67
|
-
class << conn
|
68
|
-
IGNORED_SQL = /
|
69
|
-
^(
|
70
|
-
PRAGMA | SHOW\ max_identifier_length |
|
71
|
-
SELECT\ (currval|CAST|@@IDENTITY|@@ROWCOUNT) |
|
72
|
-
SHOW\ (FIELDS|TABLES)
|
73
|
-
)\b |
|
74
|
-
\bFROM\ (sqlite_master|pg_tables|pg_attribute)\b
|
75
|
-
/x
|
76
|
-
|
77
|
-
def execute_with_counting(sql, name = nil, &block)
|
78
|
-
$query_count ||= 0
|
79
|
-
$query_count += 1 unless sql =~ IGNORED_SQL
|
80
|
-
execute_without_counting(sql, name, &block)
|
81
|
-
end
|
82
|
-
|
83
|
-
alias_method_chain :execute, :counting
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
data/test/lib/load_fixtures.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'bundler'
|
2
|
-
Bundler.setup
|
3
|
-
require 'lib/activerecord_test_connector'
|
4
|
-
|
5
|
-
# setup the connection
|
6
|
-
ActiveRecordTestConnector.setup
|
7
|
-
|
8
|
-
# load all fixtures
|
9
|
-
Fixtures.create_fixtures(ActiveRecordTestConnector::FIXTURES_PATH, ActiveRecord::Base.connection.tables)
|
10
|
-
|
11
|
-
require 'will_paginate'
|
12
|
-
WillPaginate.enable_activerecord
|
@@ -1,186 +0,0 @@
|
|
1
|
-
require 'will_paginate/core_ext'
|
2
|
-
require 'action_controller'
|
3
|
-
require 'action_controller/test_process'
|
4
|
-
|
5
|
-
require 'will_paginate'
|
6
|
-
WillPaginate.enable_actionpack
|
7
|
-
|
8
|
-
ActionController::Routing::Routes.draw do |map|
|
9
|
-
map.connect 'dummy/page/:page', :controller => 'dummy'
|
10
|
-
map.connect 'dummy/dots/page.:page', :controller => 'dummy', :action => 'dots'
|
11
|
-
map.connect 'ibocorp/:page', :controller => 'ibocorp',
|
12
|
-
:requirements => { :page => /\d+/ },
|
13
|
-
:defaults => { :page => 1 }
|
14
|
-
|
15
|
-
map.connect ':controller/:action/:id'
|
16
|
-
end
|
17
|
-
|
18
|
-
ActionController::Base.perform_caching = false
|
19
|
-
|
20
|
-
class WillPaginate::ViewTestCase < Test::Unit::TestCase
|
21
|
-
if defined?(ActionController::TestCase::Assertions)
|
22
|
-
include ActionController::TestCase::Assertions
|
23
|
-
end
|
24
|
-
if defined?(ActiveSupport::Testing::Deprecation)
|
25
|
-
include ActiveSupport::Testing::Deprecation
|
26
|
-
end
|
27
|
-
|
28
|
-
def setup
|
29
|
-
super
|
30
|
-
@controller = DummyController.new
|
31
|
-
@request = @controller.request
|
32
|
-
@html_result = nil
|
33
|
-
@template = '<%= will_paginate collection, options %>'
|
34
|
-
|
35
|
-
@view = ActionView::Base.new
|
36
|
-
@view.assigns['controller'] = @controller
|
37
|
-
@view.assigns['_request'] = @request
|
38
|
-
@view.assigns['_params'] = @request.params
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_no_complain; end
|
42
|
-
|
43
|
-
protected
|
44
|
-
|
45
|
-
def paginate(collection = {}, options = {}, &block)
|
46
|
-
if collection.instance_of? Hash
|
47
|
-
page_options = { :page => 1, :total_entries => 11, :per_page => 4 }.merge(collection)
|
48
|
-
collection = [1].paginate(page_options)
|
49
|
-
end
|
50
|
-
|
51
|
-
locals = { :collection => collection, :options => options }
|
52
|
-
|
53
|
-
unless @view.respond_to? :render_template
|
54
|
-
# Rails 2.2
|
55
|
-
@html_result = ActionView::InlineTemplate.new(@template).render(@view, locals)
|
56
|
-
else
|
57
|
-
if defined? ActionView::InlineTemplate
|
58
|
-
# Rails 2.1
|
59
|
-
args = [ ActionView::InlineTemplate.new(@view, @template, locals) ]
|
60
|
-
else
|
61
|
-
# older Rails versions
|
62
|
-
args = [nil, @template, nil, locals]
|
63
|
-
end
|
64
|
-
|
65
|
-
@html_result = @view.render_template(*args)
|
66
|
-
end
|
67
|
-
|
68
|
-
@html_document = HTML::Document.new(@html_result, true, false)
|
69
|
-
|
70
|
-
if block_given?
|
71
|
-
classname = options[:class] || WillPaginate::ViewHelpers.pagination_options[:class]
|
72
|
-
assert_select("div.#{classname}", 1, 'no main DIV', &block)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def response_from_page_or_rjs
|
77
|
-
@html_document.root
|
78
|
-
end
|
79
|
-
|
80
|
-
def validate_page_numbers expected, links, param_name = :page
|
81
|
-
param_pattern = /\W#{CGI.escape(param_name.to_s)}=([^&]*)/
|
82
|
-
|
83
|
-
assert_equal(expected, links.map { |e|
|
84
|
-
e['href'] =~ param_pattern
|
85
|
-
$1 ? $1.to_i : $1
|
86
|
-
})
|
87
|
-
end
|
88
|
-
|
89
|
-
def assert_links_match pattern, links = nil, numbers = nil
|
90
|
-
links ||= assert_select 'div.pagination a[href]' do |elements|
|
91
|
-
elements
|
92
|
-
end
|
93
|
-
|
94
|
-
pages = [] if numbers
|
95
|
-
|
96
|
-
links.each do |el|
|
97
|
-
assert_match pattern, el['href']
|
98
|
-
if numbers
|
99
|
-
el['href'] =~ pattern
|
100
|
-
pages << ($1.nil?? nil : $1.to_i)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
assert_equal numbers, pages, "page numbers don't match" if numbers
|
105
|
-
end
|
106
|
-
|
107
|
-
def assert_no_links_match pattern
|
108
|
-
assert_select 'div.pagination a[href]' do |elements|
|
109
|
-
elements.each do |el|
|
110
|
-
assert_no_match pattern, el['href']
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
private
|
116
|
-
|
117
|
-
def load_fixtures
|
118
|
-
# fix for Rails 1.2
|
119
|
-
@loaded_fixtures = {}
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
class DummyRequest
|
124
|
-
attr_accessor :symbolized_path_parameters
|
125
|
-
|
126
|
-
def initialize
|
127
|
-
@get = true
|
128
|
-
@params = {}
|
129
|
-
@symbolized_path_parameters = { :controller => 'foo', :action => 'bar' }
|
130
|
-
end
|
131
|
-
|
132
|
-
def get?
|
133
|
-
@get
|
134
|
-
end
|
135
|
-
|
136
|
-
def post
|
137
|
-
@get = false
|
138
|
-
end
|
139
|
-
|
140
|
-
def relative_url_root
|
141
|
-
''
|
142
|
-
end
|
143
|
-
|
144
|
-
def params(more = nil)
|
145
|
-
@params.update(more) if more
|
146
|
-
@params
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
class DummyController
|
151
|
-
attr_reader :request
|
152
|
-
attr_accessor :controller_name
|
153
|
-
|
154
|
-
def initialize
|
155
|
-
@request = DummyRequest.new
|
156
|
-
@url = ActionController::UrlRewriter.new(@request, @request.params)
|
157
|
-
end
|
158
|
-
|
159
|
-
def params
|
160
|
-
@request.params
|
161
|
-
end
|
162
|
-
|
163
|
-
def url_for(params)
|
164
|
-
@url.rewrite(params)
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
module HTML
|
169
|
-
Node.class_eval do
|
170
|
-
def inner_text
|
171
|
-
children.map(&:inner_text).join('')
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
Text.class_eval do
|
176
|
-
def inner_text
|
177
|
-
self.to_s
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
Tag.class_eval do
|
182
|
-
def inner_text
|
183
|
-
childless?? '' : super
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|