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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ebce0ac1df27c233be251b808d3a4a6009c096f90dc44fac0829c1e8474a3565
4
- data.tar.gz: 54587b03d64e9da82687d20c3d4570c3820b3f683792ade970f95e5d67721e96
3
+ metadata.gz: a6263dfb6824224c74e2383ba39b7f35abe25288dfcdd89a3dbab6f2585eb91e
4
+ data.tar.gz: c26bb41e5bf140fd2564ed63fda7ed4822f3c126a6a3b3885b27e2585dbf3647
5
5
  SHA512:
6
- metadata.gz: 8aac94bf484f63cecaa633444ae8e1dee6ffe3c0080877cc2deaf4470673475c1e21ca165bdd45c081d7c3b28efe07cc505499ac0fb148868cef1e6c070d0897
7
- data.tar.gz: 2969089e28341f2205e3f1b3e4fe9ddae6ea537bf32adf8895329632d437340ed6c09135d0efcac0e85c3cca79e349eb4890c6eafd791b79bca765b1d04a2ca7
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
- result = count
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
@@ -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 << Proc.new if block_given?
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
@@ -1,4 +1,3 @@
1
- require 'delegate'
2
1
  require 'forwardable'
3
2
 
4
3
  module WillPaginate
@@ -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
@@ -1,8 +1,8 @@
1
1
  module WillPaginate #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 3
4
- MINOR = 2
5
- TINY = 1
4
+ MINOR = 3
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -80,7 +80,7 @@ module WillPaginate
80
80
  defaults = nil
81
81
  key = keys
82
82
  end
83
- translate(key, options.merge(:default => defaults, :scope => :will_paginate))
83
+ translate(key, **options.merge(:default => defaults, :scope => :will_paginate))
84
84
  else
85
85
  super
86
86
  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 be_false
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 2 queries" do
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(2)
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
@@ -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".lit).order(:name).paginate(1, 2).all
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
@@ -42,5 +42,5 @@ RSpec.configure do |config|
42
42
  }
43
43
 
44
44
  config.mock_with :mocha
45
- config.backtrace_clean_patterns << /view_example_group/
45
+ config.backtrace_exclusion_patterns << /view_example_group/
46
46
  end
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.2.1
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: 2019-10-15 00:00:00.000000000 Z
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.2.1
87
- documentation_uri: https://www.rubydoc.info/gems/will_paginate/3.2.1
88
- source_code_uri: https://github.com/mislav/will_paginate/tree/v3.2.1
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
- rubyforge_project:
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