mislav-will_paginate 2.3.2 → 2.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/{CHANGELOG → CHANGELOG.rdoc} +7 -0
- data/README.rdoc +8 -33
- data/Rakefile +2 -2
- data/lib/will_paginate.rb +9 -13
- data/lib/will_paginate/collection.rb +6 -5
- data/lib/will_paginate/finder.rb +14 -6
- data/lib/will_paginate/version.rb +1 -1
- data/lib/will_paginate/view_helpers.rb +40 -30
- data/test/database.yml +2 -2
- data/test/finder_test.rb +27 -0
- data/test/tasks.rake +10 -7
- data/test/view_test.rb +9 -1
- metadata +5 -5
@@ -1,3 +1,10 @@
|
|
1
|
+
== 2.3.3, released 2008-08-29
|
2
|
+
|
3
|
+
* Ensure that paginate_by_sql doesn't change the original SQL query.
|
4
|
+
* RDoc love (now live at http://mislav.caboo.se/static/will_paginate/doc/)
|
5
|
+
* Rename :prev_label to :previous_label for consistency. old name still functions but is deprecated
|
6
|
+
* ActiveRecord 2.1: Remove :include option from count_all query when it's possible.
|
7
|
+
|
1
8
|
== 2.3.2, released 2008-05-16
|
2
9
|
|
3
10
|
* Fixed LinkRenderer#stringified_merge by removing "return" from iterator block
|
data/README.rdoc
CHANGED
@@ -11,32 +11,11 @@ can.
|
|
11
11
|
|
12
12
|
Some resources to get you started:
|
13
13
|
|
14
|
+
* {Installation instructions}[http://github.com/mislav/will_paginate/wikis/installation]
|
15
|
+
on {the wiki}[http://github.com/mislav/will_paginate/wikis]
|
14
16
|
* Your mind reels with questions? Join our
|
15
17
|
{Google group}[http://groups.google.com/group/will_paginate].
|
16
|
-
*
|
17
|
-
* How to report bugs: http://github.com/mislav/will_paginate/wikis/report-bugs
|
18
|
-
* Ryan Bates made an awesome screencast[http://railscasts.com/episodes/51],
|
19
|
-
check it out.
|
20
|
-
|
21
|
-
== Installation
|
22
|
-
|
23
|
-
The recommended way is that you get the gem:
|
24
|
-
|
25
|
-
gem install mislav-will_paginate --source http://gems.github.com/
|
26
|
-
|
27
|
-
After that you don't need the will_paginate <i>plugin</i> in your Rails
|
28
|
-
application anymore. Just add a simple require to the end of
|
29
|
-
"config/environment.rb":
|
30
|
-
|
31
|
-
gem 'mislav-will_paginate', '~> 2.2'
|
32
|
-
require 'will_paginate'
|
33
|
-
|
34
|
-
That's it. Remember to install the gem on <b>all</b> machines that you are
|
35
|
-
deploying to.
|
36
|
-
|
37
|
-
<i>There are extensive
|
38
|
-
{installation instructions}[http://github.com/mislav/will_paginate/wikis/installation]
|
39
|
-
on {the wiki}[http://github.com/mislav/will_paginate/wikis].</i>
|
18
|
+
* {How to report bugs}[http://github.com/mislav/will_paginate/wikis/report-bugs]
|
40
19
|
|
41
20
|
|
42
21
|
== Example usage
|
@@ -54,8 +33,7 @@ pagination, just stick this in:
|
|
54
33
|
|
55
34
|
<%= will_paginate @posts %>
|
56
35
|
|
57
|
-
You're done. (
|
58
|
-
can find the option list at WillPaginate::ViewHelpers.
|
36
|
+
You're done. (You can find the option list at WillPaginate::ViewHelpers.)
|
59
37
|
|
60
38
|
How does it know how much items to fetch per page? It asks your model by calling
|
61
39
|
its <tt>per_page</tt> class method. You can define it like this:
|
@@ -115,16 +93,13 @@ Lourens Naudé, Rick Olson, Russell Norris, Piotr Usewicz, Chris Eppstein.
|
|
115
93
|
== Usable pagination in the UI
|
116
94
|
|
117
95
|
There are some CSS styles to get you started in the "examples/" directory. They
|
118
|
-
are showcased
|
96
|
+
are {showcased online here}[http://mislav.caboo.se/static/will_paginate/].
|
119
97
|
|
120
98
|
More reading about pagination as design pattern:
|
121
99
|
|
122
|
-
* Pagination 101
|
123
|
-
|
124
|
-
* Pagination
|
125
|
-
http://www.smashingmagazine.com/2007/11/16/pagination-gallery-examples-and-good-practices/
|
126
|
-
* Pagination on Yahoo Design Pattern Library:
|
127
|
-
http://developer.yahoo.com/ypatterns/parent.php?pattern=pagination
|
100
|
+
* {Pagination 101}[http://kurafire.net/log/archive/2007/06/22/pagination-101]
|
101
|
+
* {Pagination gallery}[http://www.smashingmagazine.com/2007/11/16/pagination-gallery-examples-and-good-practices/]
|
102
|
+
* {Pagination on Yahoo Design Pattern Library}[http://developer.yahoo.com/ypatterns/parent.php?pattern=pagination]
|
128
103
|
|
129
104
|
Want to discuss, request features, ask questions? Join the
|
130
105
|
{Google group}[http://groups.google.com/group/will_paginate].
|
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
begin
|
3
|
-
hanna_dir = '/
|
3
|
+
hanna_dir = '/Users/mislav/Projects/Hanna/lib'
|
4
4
|
$:.unshift hanna_dir if File.exists? hanna_dir
|
5
5
|
require 'hanna/rdoctask'
|
6
6
|
rescue LoadError
|
@@ -14,7 +14,7 @@ task :default => :test
|
|
14
14
|
|
15
15
|
desc 'Generate RDoc documentation for the will_paginate plugin.'
|
16
16
|
Rake::RDocTask.new(:rdoc) do |rdoc|
|
17
|
-
rdoc.rdoc_files.include('README.rdoc', 'LICENSE', 'CHANGELOG').
|
17
|
+
rdoc.rdoc_files.include('README.rdoc', 'LICENSE', 'CHANGELOG.rdoc').
|
18
18
|
include('lib/**/*.rb').
|
19
19
|
exclude('lib/will_paginate/named_scope*').
|
20
20
|
exclude('lib/will_paginate/array.rb').
|
data/lib/will_paginate.rb
CHANGED
@@ -9,29 +9,29 @@ require 'active_support'
|
|
9
9
|
# Happy paginating!
|
10
10
|
module WillPaginate
|
11
11
|
class << self
|
12
|
-
# shortcut for <tt>enable_actionpack
|
12
|
+
# shortcut for <tt>enable_actionpack</tt> and <tt>enable_activerecord</tt> combined
|
13
13
|
def enable
|
14
14
|
enable_actionpack
|
15
15
|
enable_activerecord
|
16
16
|
end
|
17
17
|
|
18
|
-
#
|
18
|
+
# hooks WillPaginate::ViewHelpers into ActionView::Base
|
19
19
|
def enable_actionpack
|
20
20
|
return if ActionView::Base.instance_methods.include? 'will_paginate'
|
21
21
|
require 'will_paginate/view_helpers'
|
22
|
-
ActionView::Base.
|
22
|
+
ActionView::Base.send :include, ViewHelpers
|
23
23
|
|
24
24
|
if defined?(ActionController::Base) and ActionController::Base.respond_to? :rescue_responses
|
25
25
|
ActionController::Base.rescue_responses['WillPaginate::InvalidPage'] = :not_found
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
#
|
29
|
+
# hooks WillPaginate::Finder into ActiveRecord::Base and classes that deal
|
30
30
|
# with associations
|
31
31
|
def enable_activerecord
|
32
32
|
return if ActiveRecord::Base.respond_to? :paginate
|
33
33
|
require 'will_paginate/finder'
|
34
|
-
ActiveRecord::Base.
|
34
|
+
ActiveRecord::Base.send :include, Finder
|
35
35
|
|
36
36
|
# support pagination on associations
|
37
37
|
a = ActiveRecord::Associations
|
@@ -41,10 +41,8 @@ module WillPaginate
|
|
41
41
|
classes << a::HasManyThroughAssociation
|
42
42
|
end
|
43
43
|
}.each do |klass|
|
44
|
-
klass.
|
45
|
-
|
46
|
-
alias_method_chain :method_missing, :paginate
|
47
|
-
end
|
44
|
+
klass.send :include, Finder::ClassMethods
|
45
|
+
klass.class_eval { alias_method_chain :method_missing, :paginate }
|
48
46
|
end
|
49
47
|
end
|
50
48
|
|
@@ -61,13 +59,11 @@ module WillPaginate
|
|
61
59
|
require 'will_paginate/named_scope'
|
62
60
|
require 'will_paginate/named_scope_patch' if patch
|
63
61
|
|
64
|
-
ActiveRecord::Base.
|
65
|
-
include WillPaginate::NamedScope
|
66
|
-
end
|
62
|
+
ActiveRecord::Base.send :include, WillPaginate::NamedScope
|
67
63
|
end
|
68
64
|
end
|
69
65
|
|
70
|
-
module Deprecation
|
66
|
+
module Deprecation # :nodoc:
|
71
67
|
extend ActiveSupport::Deprecation
|
72
68
|
|
73
69
|
def self.warn(message, callstack = caller)
|
@@ -33,12 +33,12 @@ module WillPaginate
|
|
33
33
|
#
|
34
34
|
# If you are writing a library that provides a collection which you would like
|
35
35
|
# to conform to this API, you don't have to copy these methods over; simply
|
36
|
-
# make your plugin/gem dependant on the "will_paginate" gem:
|
36
|
+
# make your plugin/gem dependant on the "mislav-will_paginate" gem:
|
37
37
|
#
|
38
|
-
# gem 'will_paginate'
|
38
|
+
# gem 'mislav-will_paginate'
|
39
39
|
# require 'will_paginate/collection'
|
40
40
|
#
|
41
|
-
# #
|
41
|
+
# # WillPaginate::Collection is now available for use
|
42
42
|
class Collection < Array
|
43
43
|
attr_reader :current_page, :per_page, :total_entries, :total_pages
|
44
44
|
|
@@ -98,7 +98,7 @@ module WillPaginate
|
|
98
98
|
# Current offset of the paginated collection. If we're on the first page,
|
99
99
|
# it is always 0. If we're on the 2nd page and there are 30 entries per page,
|
100
100
|
# the offset is 30. This property is useful if you want to render ordinals
|
101
|
-
#
|
101
|
+
# side by side with records in the view: simply start with offset + 1.
|
102
102
|
def offset
|
103
103
|
(current_page - 1) * per_page
|
104
104
|
end
|
@@ -112,7 +112,8 @@ module WillPaginate
|
|
112
112
|
def next_page
|
113
113
|
current_page < total_pages ? (current_page + 1) : nil
|
114
114
|
end
|
115
|
-
|
115
|
+
|
116
|
+
# sets the <tt>total_entries</tt> property and calculates <tt>total_pages</tt>
|
116
117
|
def total_entries=(number)
|
117
118
|
@total_entries = number.to_i
|
118
119
|
@total_pages = (@total_entries / per_page.to_f).ceil
|
data/lib/will_paginate/finder.rb
CHANGED
@@ -94,8 +94,8 @@ module WillPaginate
|
|
94
94
|
# You can specify a starting page with <tt>:page</tt> (default is 1). Default
|
95
95
|
# <tt>:order</tt> is <tt>"id"</tt>, override if necessary.
|
96
96
|
#
|
97
|
-
# See http://weblog.jamisbuck.org/2007/4/6/faking-cursors-in-activerecord
|
98
|
-
# Jamis Buck describes this and
|
97
|
+
# See {Faking Cursors in ActiveRecord}[http://weblog.jamisbuck.org/2007/4/6/faking-cursors-in-activerecord]
|
98
|
+
# where Jamis Buck describes this and a more efficient way for MySQL.
|
99
99
|
def paginated_each(options = {}, &block)
|
100
100
|
options = { :order => 'id', :page => 1 }.merge options
|
101
101
|
options[:page] = options[:page].to_i
|
@@ -127,7 +127,7 @@ module WillPaginate
|
|
127
127
|
#
|
128
128
|
def paginate_by_sql(sql, options)
|
129
129
|
WillPaginate::Collection.create(*wp_parse_options(options)) do |pager|
|
130
|
-
query = sanitize_sql(sql)
|
130
|
+
query = sanitize_sql(sql.dup)
|
131
131
|
original_query = query.dup
|
132
132
|
# add limit, offset
|
133
133
|
add_limit! query, :offset => pager.offset, :limit => pager.per_page
|
@@ -184,19 +184,27 @@ module WillPaginate
|
|
184
184
|
unless options[:select] and options[:select] =~ /^\s*DISTINCT\b/i
|
185
185
|
excludees << :select # only exclude the select param if it doesn't begin with DISTINCT
|
186
186
|
end
|
187
|
+
|
187
188
|
# count expects (almost) the same options as find
|
188
189
|
count_options = options.except *excludees
|
189
190
|
|
190
191
|
# merge the hash found in :count
|
191
192
|
# this allows you to specify :select, :order, or anything else just for the count query
|
192
193
|
count_options.update options[:count] if options[:count]
|
194
|
+
|
195
|
+
# we may be in a model or an association proxy
|
196
|
+
klass = (@owner and @reflection) ? @reflection.klass : self
|
197
|
+
|
198
|
+
# forget about includes if they are irrelevant (Rails 2.1)
|
199
|
+
if count_options[:include] and
|
200
|
+
klass.private_methods.include?('references_eager_loaded_tables?') and
|
201
|
+
!klass.send(:references_eager_loaded_tables?, count_options)
|
202
|
+
count_options.delete :include
|
203
|
+
end
|
193
204
|
|
194
205
|
# we may have to scope ...
|
195
206
|
counter = Proc.new { count(count_options) }
|
196
207
|
|
197
|
-
# we may be in a model or an association proxy!
|
198
|
-
klass = (@owner and @reflection) ? @reflection.klass : self
|
199
|
-
|
200
208
|
count = if finder.index('find_') == 0 and klass.respond_to?(scoper = finder.sub('find', 'with'))
|
201
209
|
# scope_out adds a 'with_finder' method which acts like with_scope, if it's present
|
202
210
|
# then execute the count with the scoping provided by the with_finder
|
@@ -3,35 +3,36 @@ require 'will_paginate/core_ext'
|
|
3
3
|
module WillPaginate
|
4
4
|
# = Will Paginate view helpers
|
5
5
|
#
|
6
|
-
#
|
6
|
+
# The main view helper, #will_paginate, renders
|
7
7
|
# pagination links for the given collection. The helper itself is lightweight
|
8
|
-
# and serves only as a wrapper around
|
8
|
+
# and serves only as a wrapper around LinkRenderer instantiation; the
|
9
9
|
# renderer then does all the hard work of generating the HTML.
|
10
10
|
#
|
11
11
|
# == Global options for helpers
|
12
12
|
#
|
13
13
|
# Options for pagination helpers are optional and get their default values from the
|
14
|
-
# WillPaginate::ViewHelpers.pagination_options hash. You can write to this hash to
|
14
|
+
# <tt>WillPaginate::ViewHelpers.pagination_options</tt> hash. You can write to this hash to
|
15
15
|
# override default options on the global level:
|
16
16
|
#
|
17
|
-
# WillPaginate::ViewHelpers.pagination_options[:
|
17
|
+
# WillPaginate::ViewHelpers.pagination_options[:previous_label] = 'Previous page'
|
18
18
|
#
|
19
|
-
# By putting this into
|
19
|
+
# By putting this into "config/initializers/will_paginate.rb" (or simply environment.rb in
|
20
|
+
# older versions of Rails) you can easily translate link texts to previous
|
20
21
|
# and next pages, as well as override some other defaults to your liking.
|
21
22
|
module ViewHelpers
|
22
23
|
# default options that can be overridden on the global level
|
23
24
|
@@pagination_options = {
|
24
|
-
:class
|
25
|
-
:
|
26
|
-
:next_label
|
27
|
-
:inner_window
|
28
|
-
:outer_window
|
29
|
-
:separator
|
30
|
-
:param_name
|
31
|
-
:params
|
32
|
-
:renderer
|
33
|
-
:page_links
|
34
|
-
:container
|
25
|
+
:class => 'pagination',
|
26
|
+
:previous_label => '« Previous',
|
27
|
+
:next_label => 'Next »',
|
28
|
+
:inner_window => 4, # links around the current page
|
29
|
+
:outer_window => 1, # links around beginning and end
|
30
|
+
:separator => ' ', # single space is friendly to spiders and non-graphic browsers
|
31
|
+
:param_name => :page,
|
32
|
+
:params => nil,
|
33
|
+
:renderer => 'WillPaginate::LinkRenderer',
|
34
|
+
:page_links => true,
|
35
|
+
:container => true
|
35
36
|
}
|
36
37
|
mattr_reader :pagination_options
|
37
38
|
|
@@ -40,32 +41,37 @@ module WillPaginate
|
|
40
41
|
# rendering the pagination in that case...
|
41
42
|
#
|
42
43
|
# ==== Options
|
43
|
-
#
|
44
|
-
# * <tt>:
|
44
|
+
# Display options:
|
45
|
+
# * <tt>:previous_label</tt> -- default: "« Previous" (this parameter is called <tt>:prev_label</tt> in versions <b>2.3.2</b> and older!)
|
45
46
|
# * <tt>:next_label</tt> -- default: "Next »"
|
47
|
+
# * <tt>:page_links</tt> -- when false, only previous/next links are rendered (default: true)
|
46
48
|
# * <tt>:inner_window</tt> -- how many links are shown around the current page (default: 4)
|
47
49
|
# * <tt>:outer_window</tt> -- how many links are around the first and the last page (default: 1)
|
48
50
|
# * <tt>:separator</tt> -- string separator for page HTML elements (default: single space)
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
52
|
-
# * <tt>:renderer</tt> -- class name, class or instance of a link renderer (default:
|
53
|
-
# <tt>WillPaginate::LinkRenderer</tt>)
|
54
|
-
# * <tt>:page_links</tt> -- when false, only previous/next links are rendered (default: true)
|
51
|
+
#
|
52
|
+
# HTML options:
|
53
|
+
# * <tt>:class</tt> -- CSS class name for the generated DIV (default: "pagination")
|
55
54
|
# * <tt>:container</tt> -- toggles rendering of the DIV container for pagination links, set to
|
56
55
|
# false only when you are rendering your own pagination markup (default: true)
|
57
56
|
# * <tt>:id</tt> -- HTML ID for the container (default: nil). Pass +true+ to have the ID
|
58
57
|
# automatically generated from the class name of objects in collection: for example, paginating
|
59
58
|
# ArticleComment models would yield an ID of "article_comments_pagination".
|
60
59
|
#
|
61
|
-
#
|
60
|
+
# Advanced options:
|
61
|
+
# * <tt>:param_name</tt> -- parameter name for page number in URLs (default: <tt>:page</tt>)
|
62
|
+
# * <tt>:params</tt> -- additional parameters when generating pagination links
|
63
|
+
# (eg. <tt>:controller => "foo", :action => nil</tt>)
|
64
|
+
# * <tt>:renderer</tt> -- class name, class or instance of a link renderer (default:
|
65
|
+
# <tt>WillPaginate::LinkRenderer</tt>)
|
66
|
+
#
|
67
|
+
# All options not recognized by will_paginate will become HTML attributes on the container
|
62
68
|
# element for pagination links (the DIV). For example:
|
63
69
|
#
|
64
|
-
# <%= will_paginate @posts, :
|
70
|
+
# <%= will_paginate @posts, :style => 'font-size: small' %>
|
65
71
|
#
|
66
72
|
# ... will result in:
|
67
73
|
#
|
68
|
-
# <div class="pagination"
|
74
|
+
# <div class="pagination" style="font-size: small"> ... </div>
|
69
75
|
#
|
70
76
|
# ==== Using the helper without arguments
|
71
77
|
# If the helper is called without passing in the collection object, it will
|
@@ -92,6 +98,10 @@ module WillPaginate
|
|
92
98
|
return nil unless WillPaginate::ViewHelpers.total_pages_for_collection(collection) > 1
|
93
99
|
|
94
100
|
options = options.symbolize_keys.reverse_merge WillPaginate::ViewHelpers.pagination_options
|
101
|
+
if options[:prev_label]
|
102
|
+
WillPaginate::Deprecation::warn(":prev_label view parameter is now :previous_label; the old name has been deprecated.")
|
103
|
+
options[:previous_label] = options.delete(:prev_label)
|
104
|
+
end
|
95
105
|
|
96
106
|
# get the renderer instance
|
97
107
|
renderer = case options[:renderer]
|
@@ -143,7 +153,7 @@ module WillPaginate
|
|
143
153
|
#
|
144
154
|
# By default, the message will use the humanized class name of objects
|
145
155
|
# in collection: for instance, "project types" for ProjectType models.
|
146
|
-
# Override this
|
156
|
+
# Override this with the <tt>:entry_name</tt> parameter:
|
147
157
|
#
|
148
158
|
# <%= page_entries_info @posts, :entry_name => 'item' %>
|
149
159
|
# #-> Displaying items 6 - 10 of 26 in total
|
@@ -183,7 +193,7 @@ module WillPaginate
|
|
183
193
|
end
|
184
194
|
|
185
195
|
# This class does the heavy lifting of actually building the pagination
|
186
|
-
# links. It is used by
|
196
|
+
# links. It is used by the <tt>will_paginate</tt> helper internally.
|
187
197
|
class LinkRenderer
|
188
198
|
|
189
199
|
# The gap in page links is represented by:
|
@@ -214,7 +224,7 @@ module WillPaginate
|
|
214
224
|
def to_html
|
215
225
|
links = @options[:page_links] ? windowed_links : []
|
216
226
|
# previous/next buttons
|
217
|
-
links.unshift page_link_or_span(@collection.previous_page, 'disabled prev_page', @options[:
|
227
|
+
links.unshift page_link_or_span(@collection.previous_page, 'disabled prev_page', @options[:previous_label])
|
218
228
|
links.push page_link_or_span(@collection.next_page, 'disabled next_page', @options[:next_label])
|
219
229
|
|
220
230
|
html = links.join(@options[:separator])
|
data/test/database.yml
CHANGED
data/test/finder_test.rb
CHANGED
@@ -397,6 +397,15 @@ class FinderTest < ActiveRecordTestCase
|
|
397
397
|
Developer.paginate(options)
|
398
398
|
assert_equal options, options_before
|
399
399
|
end
|
400
|
+
|
401
|
+
def test_paginate_by_sql_doesnt_change_original_query
|
402
|
+
query = 'SQL QUERY'
|
403
|
+
original_query = query.dup
|
404
|
+
Developer.expects(:find_by_sql).returns([])
|
405
|
+
|
406
|
+
Developer.paginate_by_sql query, :page => 1
|
407
|
+
assert_equal original_query, query
|
408
|
+
end
|
400
409
|
|
401
410
|
def test_paginated_each
|
402
411
|
collection = stub('collection', :size => 5, :empty? => false, :per_page => 5)
|
@@ -412,5 +421,23 @@ class FinderTest < ActiveRecordTestCase
|
|
412
421
|
|
413
422
|
assert_equal 14, Developer.paginated_each(:page => '2') { }
|
414
423
|
end
|
424
|
+
|
425
|
+
# detect ActiveRecord 2.1
|
426
|
+
if ActiveRecord::Base.private_methods.include?('references_eager_loaded_tables?')
|
427
|
+
def test_removes_irrelevant_includes_in_count
|
428
|
+
Developer.expects(:find).returns([1])
|
429
|
+
Developer.expects(:count).with({}).returns(0)
|
430
|
+
|
431
|
+
Developer.paginate :page => 1, :per_page => 1, :include => :projects
|
432
|
+
end
|
433
|
+
|
434
|
+
def test_doesnt_remove_referenced_includes_in_count
|
435
|
+
Developer.expects(:find).returns([1])
|
436
|
+
Developer.expects(:count).with({ :include => :projects, :conditions => 'projects.id > 2' }).returns(0)
|
437
|
+
|
438
|
+
Developer.paginate :page => 1, :per_page => 1,
|
439
|
+
:include => :projects, :conditions => 'projects.id > 2'
|
440
|
+
end
|
441
|
+
end
|
415
442
|
end
|
416
443
|
end
|
data/test/tasks.rake
CHANGED
@@ -32,18 +32,21 @@ task :test_databases => %w(test_mysql test_sqlite3 test_postgres)
|
|
32
32
|
desc %{Test everything on SQLite3, MySQL and PostgreSQL}
|
33
33
|
task :test_full => %w(test test_mysql test_postgres)
|
34
34
|
|
35
|
-
desc %{Test everything with Rails 1.2.x
|
35
|
+
desc %{Test everything with Rails 2.1.x, 2.0.x & 1.2.x gems}
|
36
36
|
task :test_all do
|
37
37
|
all = Rake::Task['test_full']
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
versions = %w(2.1.0 2.0.2 1.2.6)
|
39
|
+
versions.each do |version|
|
40
|
+
ENV['RAILS_VERSION'] = "~> #{version}"
|
41
|
+
all.invoke
|
42
|
+
reset_invoked unless version == versions.last
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def reset_invoked
|
41
47
|
%w( test_full test test_mysql test_postgres ).each do |name|
|
42
48
|
Rake::Task[name].instance_variable_set '@already_invoked', false
|
43
49
|
end
|
44
|
-
# do it again
|
45
|
-
ENV['RAILS_VERSION'] = '~>2.0.2'
|
46
|
-
all.invoke
|
47
50
|
end
|
48
51
|
|
49
52
|
task :rcov do
|
data/test/view_test.rb
CHANGED
@@ -36,7 +36,7 @@ class ViewTest < WillPaginate::ViewTestCase
|
|
36
36
|
|
37
37
|
def test_will_paginate_with_options
|
38
38
|
paginate({ :page => 2 },
|
39
|
-
:class => 'will_paginate', :
|
39
|
+
:class => 'will_paginate', :previous_label => 'Prev', :next_label => 'Next') do
|
40
40
|
assert_select 'a[href]', 4 do |elements|
|
41
41
|
validate_page_numbers [1,1,3,3], elements
|
42
42
|
# test rel attribute values:
|
@@ -80,6 +80,14 @@ class ViewTest < WillPaginate::ViewTestCase
|
|
80
80
|
assert_select 'a.next_page[href]:last-child'
|
81
81
|
end
|
82
82
|
end
|
83
|
+
|
84
|
+
def test_prev_label_deprecated
|
85
|
+
assert_deprecated ':previous_label' do
|
86
|
+
paginate({ :page => 2 }, :prev_label => 'Deprecated') do
|
87
|
+
assert_select 'a[href]:first-child', 'Deprecated'
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
83
91
|
|
84
92
|
def test_full_output
|
85
93
|
paginate
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mislav-will_paginate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Mislav Marohni\xC4\x87"
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2008-
|
13
|
+
date: 2008-08-29 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -31,9 +31,9 @@ extensions: []
|
|
31
31
|
extra_rdoc_files:
|
32
32
|
- README.rdoc
|
33
33
|
- LICENSE
|
34
|
-
- CHANGELOG
|
34
|
+
- CHANGELOG.rdoc
|
35
35
|
files:
|
36
|
-
- CHANGELOG
|
36
|
+
- CHANGELOG.rdoc
|
37
37
|
- LICENSE
|
38
38
|
- README.rdoc
|
39
39
|
- Rakefile
|
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
107
|
requirements: []
|
108
108
|
|
109
109
|
rubyforge_project:
|
110
|
-
rubygems_version: 1.0
|
110
|
+
rubygems_version: 1.2.0
|
111
111
|
signing_key:
|
112
112
|
specification_version: 2
|
113
113
|
summary: Most awesome pagination solution for Rails
|