will_paginate 2.3.16 → 2.3.17
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.
- data/lib/will_paginate/finder.rb +7 -2
- data/lib/will_paginate/version.rb +1 -1
- data/test/ci.rb +4 -0
- data/test/database.yml +1 -1
- data/test/finder_test.rb +10 -3
- data/test/view_test.rb +8 -1
- metadata +18 -5
data/lib/will_paginate/finder.rb
CHANGED
|
@@ -97,7 +97,8 @@ module WillPaginate
|
|
|
97
97
|
# See {Faking Cursors in ActiveRecord}[http://weblog.jamisbuck.org/2007/4/6/faking-cursors-in-activerecord]
|
|
98
98
|
# where Jamis Buck describes this and a more efficient way for MySQL.
|
|
99
99
|
def paginated_each(options = {})
|
|
100
|
-
|
|
100
|
+
order = scope(:find, :order) || 'id'
|
|
101
|
+
options = { :order => order, :page => 1 }.merge options
|
|
101
102
|
options[:page] = options[:page].to_i
|
|
102
103
|
options[:total_entries] = 0 # skip the individual count queries
|
|
103
104
|
total = 0
|
|
@@ -160,7 +161,11 @@ module WillPaginate
|
|
|
160
161
|
end
|
|
161
162
|
|
|
162
163
|
protected
|
|
163
|
-
|
|
164
|
+
|
|
165
|
+
def respond_to_missing?(method, include_private = false)
|
|
166
|
+
method.to_s.index('paginate') == 0 || super
|
|
167
|
+
end
|
|
168
|
+
|
|
164
169
|
def method_missing_with_paginate(method, *args) #:nodoc:
|
|
165
170
|
# did somebody tried to paginate? if not, let them be
|
|
166
171
|
unless method.to_s.index('paginate') == 0
|
data/test/ci.rb
CHANGED
|
@@ -45,6 +45,10 @@ gemfiles.each do |gemfile|
|
|
|
45
45
|
next if 'mysql' == db and !run_mysql
|
|
46
46
|
announce "Rails #{version}", "with #{db}"
|
|
47
47
|
ENV['DB'] = db
|
|
48
|
+
if db == 'postgres' && !ENV['TRAVIS']
|
|
49
|
+
system "psql -c 'drop database will_paginate;' &>/dev/null"
|
|
50
|
+
system "psql -c 'create database will_paginate;' >/dev/null"
|
|
51
|
+
end
|
|
48
52
|
failed = true unless system %(bundle exec rake)
|
|
49
53
|
end
|
|
50
54
|
else
|
data/test/database.yml
CHANGED
data/test/finder_test.rb
CHANGED
|
@@ -100,7 +100,7 @@ class FinderTest < ActiveRecordTestCase
|
|
|
100
100
|
end
|
|
101
101
|
|
|
102
102
|
def test_paginate_with_conditions
|
|
103
|
-
entries = Topic.paginate :page => 1, :conditions => ["created_at > ?", 30.minutes.ago]
|
|
103
|
+
entries = Topic.paginate :page => 1, :conditions => ["created_at > ?", 30.minutes.ago], :order => :id
|
|
104
104
|
expected = [topics(:rails), topics(:ar)]
|
|
105
105
|
assert_equal expected, entries.to_a
|
|
106
106
|
assert_equal 1, entries.total_pages
|
|
@@ -190,7 +190,7 @@ class FinderTest < ActiveRecordTestCase
|
|
|
190
190
|
end
|
|
191
191
|
|
|
192
192
|
def test_paginate_association_extension
|
|
193
|
-
project = Project.find(:first)
|
|
193
|
+
project = Project.find(:first, :order => :id)
|
|
194
194
|
|
|
195
195
|
assert_queries(2) do
|
|
196
196
|
entries = project.replies.paginate_recent :page => 1
|
|
@@ -241,7 +241,7 @@ class FinderTest < ActiveRecordTestCase
|
|
|
241
241
|
assert_equal entries, Developer.paginate_by_salary(100000, :page => 1, :per_page => 5)
|
|
242
242
|
|
|
243
243
|
# dynamic finder + conditions
|
|
244
|
-
entries = Developer.paginate_by_salary(100000, :page => 1,
|
|
244
|
+
entries = Developer.paginate_by_salary(100000, :page => 1, :order => :id,
|
|
245
245
|
:conditions => ['id > ?', 6])
|
|
246
246
|
assert_equal 4, entries.total_entries
|
|
247
247
|
assert_equal (7..10).to_a, entries.map(&:id)
|
|
@@ -308,6 +308,13 @@ class FinderTest < ActiveRecordTestCase
|
|
|
308
308
|
assert_equal 1, entries.size
|
|
309
309
|
end
|
|
310
310
|
|
|
311
|
+
def test_paginated_each_with_scoped_order
|
|
312
|
+
paginated_developers = []
|
|
313
|
+
Developer.poor.paginated_each {|d| paginated_developers << d}
|
|
314
|
+
|
|
315
|
+
assert_equal Developer.poor.find(:all), paginated_developers, 'should use scoped :order option'
|
|
316
|
+
end
|
|
317
|
+
|
|
311
318
|
## misc ##
|
|
312
319
|
|
|
313
320
|
def test_count_and_total_entries_options_are_mutually_exclusive
|
data/test/view_test.rb
CHANGED
|
@@ -241,7 +241,14 @@ class ViewTest < WillPaginate::ViewTestCase
|
|
|
241
241
|
paginate
|
|
242
242
|
assert_links_match /foo%5Bbar%5D=baz/
|
|
243
243
|
end
|
|
244
|
-
|
|
244
|
+
|
|
245
|
+
def test_will_paginate_prevents_host_and_protocol_tampering
|
|
246
|
+
@request.params :host => 'disney.com', :protocol => 'javascript'
|
|
247
|
+
paginate
|
|
248
|
+
assert_no_links_match /disney/
|
|
249
|
+
assert_no_links_match /javascript/
|
|
250
|
+
end
|
|
251
|
+
|
|
245
252
|
def test_will_paginate_doesnt_preserve_parameters_on_post
|
|
246
253
|
@request.post
|
|
247
254
|
@request.params :foo => 'bar'
|
metadata
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: will_paginate
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
+
hash: 33
|
|
4
5
|
prerelease:
|
|
5
|
-
|
|
6
|
+
segments:
|
|
7
|
+
- 2
|
|
8
|
+
- 3
|
|
9
|
+
- 17
|
|
10
|
+
version: 2.3.17
|
|
6
11
|
platform: ruby
|
|
7
12
|
authors:
|
|
8
13
|
- "Mislav Marohni\xC4\x87"
|
|
@@ -11,7 +16,8 @@ autorequire:
|
|
|
11
16
|
bindir: bin
|
|
12
17
|
cert_chain: []
|
|
13
18
|
|
|
14
|
-
date:
|
|
19
|
+
date: 2016-10-15 00:00:00 +02:00
|
|
20
|
+
default_executable:
|
|
15
21
|
dependencies: []
|
|
16
22
|
|
|
17
23
|
description: will_paginate provides a simple API for Active Record pagination and rendering of pagination links in Rails templates.
|
|
@@ -72,9 +78,10 @@ files:
|
|
|
72
78
|
- README.md
|
|
73
79
|
- LICENSE
|
|
74
80
|
- CHANGELOG.rdoc
|
|
81
|
+
has_rdoc: true
|
|
75
82
|
homepage: https://github.com/mislav/will_paginate/wiki
|
|
76
|
-
licenses:
|
|
77
|
-
|
|
83
|
+
licenses:
|
|
84
|
+
- MIT
|
|
78
85
|
post_install_message:
|
|
79
86
|
rdoc_options:
|
|
80
87
|
- --main
|
|
@@ -87,17 +94,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
87
94
|
requirements:
|
|
88
95
|
- - ">="
|
|
89
96
|
- !ruby/object:Gem::Version
|
|
97
|
+
hash: 3
|
|
98
|
+
segments:
|
|
99
|
+
- 0
|
|
90
100
|
version: "0"
|
|
91
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
102
|
none: false
|
|
93
103
|
requirements:
|
|
94
104
|
- - ">="
|
|
95
105
|
- !ruby/object:Gem::Version
|
|
106
|
+
hash: 3
|
|
107
|
+
segments:
|
|
108
|
+
- 0
|
|
96
109
|
version: "0"
|
|
97
110
|
requirements: []
|
|
98
111
|
|
|
99
112
|
rubyforge_project:
|
|
100
|
-
rubygems_version: 1.
|
|
113
|
+
rubygems_version: 1.6.2
|
|
101
114
|
signing_key:
|
|
102
115
|
specification_version: 3
|
|
103
116
|
summary: Easy pagination for Rails
|