will_paginate 3.2.1 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/will_paginate/active_record.rb +3 -3
- data/lib/will_paginate/i18n.rb +3 -3
- data/lib/will_paginate/page_number.rb +0 -1
- data/lib/will_paginate/railtie.rb +2 -2
- data/lib/will_paginate/version.rb +2 -2
- data/lib/will_paginate/view_helpers/action_view.rb +1 -1
- data/spec/finders/active_record_spec.rb +10 -3
- data/spec/finders/mongoid_spec.rb +2 -0
- data/spec/finders/sequel_spec.rb +7 -6
- data/spec/spec_helper.rb +1 -1
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6263dfb6824224c74e2383ba39b7f35abe25288dfcdd89a3dbab6f2585eb91e
|
4
|
+
data.tar.gz: c26bb41e5bf140fd2564ed63fda7ed4822f3c126a6a3b3885b27e2585dbf3647
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f67913552fff8839f5de82d9e55c61ad69c1a57216da3d5d627aef77455ee32a03d2b8c2b732299b37481ea6e9fd72a5baa1432e1fe296e78fc06b6a46ee8e0
|
7
|
+
data.tar.gz: 8979fdd5d35ee416e4c607f759b8e868188b11bb2ca7540d982866e936168170519492a027fff90cb31db12fb758b144389691c9374acfd58fd1880105d2201c
|
@@ -105,9 +105,7 @@ module WillPaginate
|
|
105
105
|
# overloaded to be pagination-aware
|
106
106
|
def empty?
|
107
107
|
if !loaded? and offset_value
|
108
|
-
|
109
|
-
result = result.size if result.respond_to?(:size) and !result.is_a?(Integer)
|
110
|
-
result <= offset_value
|
108
|
+
total_entries <= offset_value
|
111
109
|
else
|
112
110
|
super
|
113
111
|
end
|
@@ -212,6 +210,8 @@ module WillPaginate
|
|
212
210
|
WHERE rownum <= #{pager.offset + pager.per_page}
|
213
211
|
) WHERE rnum >= #{pager.offset}
|
214
212
|
SQL
|
213
|
+
elsif (self.connection.adapter_name =~ /^sqlserver/i)
|
214
|
+
query << " OFFSET #{pager.offset} ROWS FETCH NEXT #{pager.per_page} ROWS ONLY"
|
215
215
|
else
|
216
216
|
query << " LIMIT #{pager.per_page} OFFSET #{pager.offset}"
|
217
217
|
end
|
data/lib/will_paginate/i18n.rb
CHANGED
@@ -8,11 +8,11 @@ module WillPaginate
|
|
8
8
|
Dir["#{locale_dir}/*.{rb,yml}"]
|
9
9
|
end
|
10
10
|
|
11
|
-
def will_paginate_translate(keys, options = {})
|
11
|
+
def will_paginate_translate(keys, options = {}, &block)
|
12
12
|
if defined? ::I18n
|
13
13
|
defaults = Array(keys).dup
|
14
|
-
defaults <<
|
15
|
-
::I18n.translate(defaults.shift, options.merge(:default => defaults, :scope => :will_paginate))
|
14
|
+
defaults << block if block_given?
|
15
|
+
::I18n.translate(defaults.shift, **options.merge(:default => defaults, :scope => :will_paginate))
|
16
16
|
else
|
17
17
|
key = Array === keys ? keys.first : keys
|
18
18
|
yield key, options
|
@@ -59,11 +59,11 @@ module WillPaginate
|
|
59
59
|
end
|
60
60
|
|
61
61
|
module ControllerRescuePatch
|
62
|
-
def rescue_from(*args, &block)
|
62
|
+
def rescue_from(*args, **kwargs, &block)
|
63
63
|
if idx = args.index(WillPaginate::InvalidPage)
|
64
64
|
args[idx] = args[idx].name
|
65
65
|
end
|
66
|
-
super(*args, &block)
|
66
|
+
super(*args, **kwargs, &block)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
@@ -163,6 +163,13 @@ describe WillPaginate::ActiveRecord do
|
|
163
163
|
topics.total_entries.should == 999
|
164
164
|
end
|
165
165
|
|
166
|
+
it "overrides empty? count call with a total_entries fixed value" do
|
167
|
+
lambda {
|
168
|
+
topics = Topic.paginate :page => 1, :per_page => 3, :total_entries => 999
|
169
|
+
topics.should_not be_empty
|
170
|
+
}.should run_queries(0)
|
171
|
+
end
|
172
|
+
|
166
173
|
it "removes :include for count" do
|
167
174
|
lambda {
|
168
175
|
developers = Developer.paginate(:page => 1, :per_page => 1).includes(:projects)
|
@@ -213,7 +220,7 @@ describe WillPaginate::ActiveRecord do
|
|
213
220
|
sql = "select content from topics where content like '%futurama%'"
|
214
221
|
topics = Topic.paginate_by_sql sql, :page => 1, :per_page => 1
|
215
222
|
topics.total_entries.should == 1
|
216
|
-
topics.first.attributes.has_key?('title').should
|
223
|
+
topics.first.attributes.has_key?('title').should be(false)
|
217
224
|
}.should run_queries(2)
|
218
225
|
end
|
219
226
|
|
@@ -271,12 +278,12 @@ describe WillPaginate::ActiveRecord do
|
|
271
278
|
}.should run_queries(1)
|
272
279
|
end
|
273
280
|
|
274
|
-
it "should get second (inexistent) page of Topics, requiring
|
281
|
+
it "should get second (inexistent) page of Topics, requiring 1 query" do
|
275
282
|
lambda {
|
276
283
|
result = Topic.paginate :page => 2
|
277
284
|
result.total_pages.should == 1
|
278
285
|
result.should be_empty
|
279
|
-
}.should run_queries(
|
286
|
+
}.should run_queries(1)
|
280
287
|
end
|
281
288
|
|
282
289
|
describe "associations" do
|
@@ -10,6 +10,8 @@ if !ENV['SKIP_NONRAILS_TESTS']
|
|
10
10
|
require 'will_paginate/mongoid'
|
11
11
|
Object.send(:const_set, :Rails, old_rails) if old_rails
|
12
12
|
|
13
|
+
Mongo::Logger.logger.level = Logger::INFO
|
14
|
+
|
13
15
|
Mongoid.connect_to 'will_paginate_test'
|
14
16
|
class MongoidModel
|
15
17
|
include Mongoid::Document
|
data/spec/finders/sequel_spec.rb
CHANGED
@@ -11,14 +11,15 @@ end
|
|
11
11
|
describe Sequel::Dataset::Pagination, 'extension' do
|
12
12
|
|
13
13
|
class Car < Sequel::Model
|
14
|
+
self.dataset = dataset.extension(:pagination)
|
14
15
|
end
|
15
16
|
|
16
17
|
it "should have the #paginate method" do
|
17
|
-
Car.should respond_to(:paginate)
|
18
|
+
Car.dataset.should respond_to(:paginate)
|
18
19
|
end
|
19
20
|
|
20
21
|
it "should NOT have the #paginate_by_sql method" do
|
21
|
-
Car.should_not respond_to(:paginate_by_sql)
|
22
|
+
Car.dataset.should_not respond_to(:paginate_by_sql)
|
22
23
|
end
|
23
24
|
|
24
25
|
describe 'pagination' do
|
@@ -29,7 +30,7 @@ describe Sequel::Dataset::Pagination, 'extension' do
|
|
29
30
|
end
|
30
31
|
|
31
32
|
it "should imitate WillPaginate::Collection" do
|
32
|
-
result = Car.paginate(1, 2)
|
33
|
+
result = Car.dataset.paginate(1, 2)
|
33
34
|
|
34
35
|
result.should_not be_empty
|
35
36
|
result.size.should == 2
|
@@ -41,16 +42,16 @@ describe Sequel::Dataset::Pagination, 'extension' do
|
|
41
42
|
end
|
42
43
|
|
43
44
|
it "should perform" do
|
44
|
-
Car.paginate(1, 2).all.should == [Car[1], Car[2]]
|
45
|
+
Car.dataset.paginate(1, 2).all.should == [Car[1], Car[2]]
|
45
46
|
end
|
46
47
|
|
47
48
|
it "should be empty" do
|
48
|
-
result = Car.paginate(3, 2)
|
49
|
+
result = Car.dataset.paginate(3, 2)
|
49
50
|
result.should be_empty
|
50
51
|
end
|
51
52
|
|
52
53
|
it "should perform with #select and #order" do
|
53
|
-
result = Car.select("name as foo"
|
54
|
+
result = Car.select(Sequel.lit("name as foo")).order(:name).paginate(1, 2).all
|
54
55
|
result.size.should == 2
|
55
56
|
result.first.values[:foo].should == "Aston Martin"
|
56
57
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: will_paginate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mislav Marohnić
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: will_paginate provides a simple API for performing paginated queries
|
14
14
|
with Active Record, DataMapper and Sequel, and includes helpers for rendering pagination
|
@@ -83,9 +83,9 @@ licenses:
|
|
83
83
|
- MIT
|
84
84
|
metadata:
|
85
85
|
bug_tracker_uri: https://github.com/mislav/will_paginate/issues
|
86
|
-
changelog_uri: https://github.com/mislav/will_paginate/releases/tag/v3.
|
87
|
-
documentation_uri: https://www.rubydoc.info/gems/will_paginate/3.
|
88
|
-
source_code_uri: https://github.com/mislav/will_paginate/tree/v3.
|
86
|
+
changelog_uri: https://github.com/mislav/will_paginate/releases/tag/v3.3.0
|
87
|
+
documentation_uri: https://www.rubydoc.info/gems/will_paginate/3.3.0
|
88
|
+
source_code_uri: https://github.com/mislav/will_paginate/tree/v3.3.0
|
89
89
|
wiki_uri: https://github.com/mislav/will_paginate/wiki
|
90
90
|
post_install_message:
|
91
91
|
rdoc_options:
|
@@ -98,15 +98,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
98
|
requirements:
|
99
99
|
- - ">="
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version: '0'
|
101
|
+
version: '2.0'
|
102
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
103
|
requirements:
|
104
104
|
- - ">="
|
105
105
|
- !ruby/object:Gem::Version
|
106
106
|
version: '0'
|
107
107
|
requirements: []
|
108
|
-
|
109
|
-
rubygems_version: 2.7.6
|
108
|
+
rubygems_version: 3.1.2
|
110
109
|
signing_key:
|
111
110
|
specification_version: 4
|
112
111
|
summary: Pagination plugin for web frameworks and other apps
|