will_paginate 3.0.2 → 3.0.3
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.
@@ -51,7 +51,9 @@ module WillPaginate
|
|
51
51
|
if loaded? and @array.size < per_page and (current_page == 1 or @array.size > 0)
|
52
52
|
offset + @array.size
|
53
53
|
else
|
54
|
-
|
54
|
+
# :reload prevents Collection.filter from being run, which
|
55
|
+
# would cause a stack overflow
|
56
|
+
clean_query = query.merge(:reload => true)
|
55
57
|
# seems like the only way
|
56
58
|
clean_query.instance_variable_set('@limit', nil)
|
57
59
|
clean_query.instance_variable_set('@offset', 0)
|
@@ -61,9 +63,13 @@ module WillPaginate
|
|
61
63
|
end
|
62
64
|
|
63
65
|
def to_a
|
64
|
-
|
65
|
-
|
66
|
-
|
66
|
+
if paginated?
|
67
|
+
::WillPaginate::Collection.create(current_page, per_page) do |col|
|
68
|
+
col.replace super
|
69
|
+
col.total_entries ||= total_entries
|
70
|
+
end
|
71
|
+
else
|
72
|
+
super
|
67
73
|
end
|
68
74
|
end
|
69
75
|
|
@@ -25,7 +25,9 @@ module WillPaginate
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.setup_actioncontroller
|
28
|
-
ActionDispatch::
|
28
|
+
( defined?(ActionDispatch::ExceptionWrapper) ?
|
29
|
+
ActionDispatch::ExceptionWrapper : ActionDispatch::ShowExceptions
|
30
|
+
).send :include, ShowExceptionsPatch
|
29
31
|
ActionController::Base.extend ControllerRescuePatch
|
30
32
|
end
|
31
33
|
|
@@ -39,13 +41,18 @@ module WillPaginate
|
|
39
41
|
extend ActiveSupport::Concern
|
40
42
|
included { alias_method_chain :status_code, :paginate }
|
41
43
|
private
|
42
|
-
def status_code_with_paginate(exception)
|
44
|
+
def status_code_with_paginate(exception = @exception)
|
43
45
|
if exception.is_a?(WillPaginate::InvalidPage) or
|
44
46
|
(exception.respond_to?(:original_exception) &&
|
45
47
|
exception.original_exception.is_a?(WillPaginate::InvalidPage))
|
46
48
|
Rack::Utils.status_code(:not_found)
|
47
49
|
else
|
48
|
-
status_code_without_paginate
|
50
|
+
original_method = method(:status_code_without_paginate)
|
51
|
+
if original_method.arity != 0
|
52
|
+
original_method.call(exception)
|
53
|
+
else
|
54
|
+
original_method.call()
|
55
|
+
end
|
49
56
|
end
|
50
57
|
end
|
51
58
|
end
|
@@ -279,7 +279,8 @@ describe WillPaginate::ActiveRecord do
|
|
279
279
|
end
|
280
280
|
|
281
281
|
it "should paginate with :conditions" do
|
282
|
-
result = Topic.paginate :page => 1, :
|
282
|
+
result = Topic.paginate :page => 1, :order => 'id ASC',
|
283
|
+
:conditions => ["created_at > ?", 30.minutes.ago]
|
283
284
|
result.should == topics(:rails, :ar)
|
284
285
|
result.total_pages.should == 1
|
285
286
|
end
|
@@ -80,4 +80,24 @@ describe WillPaginate::DataMapper do
|
|
80
80
|
Animal.all(:conditions => ['1=2']).page(1).total_pages.should == 1
|
81
81
|
end
|
82
82
|
|
83
|
+
it "can iterate and then call WP methods" do
|
84
|
+
animals = Animal.all(:limit => 2).page(1)
|
85
|
+
animals.each { |a| }
|
86
|
+
animals.total_entries.should == 3
|
87
|
+
end
|
88
|
+
|
89
|
+
it "augments to_a to return a WP::Collection" do
|
90
|
+
animals = Animal.all(:limit => 2).page(1)
|
91
|
+
array = animals.to_a
|
92
|
+
array.size.should == 2
|
93
|
+
array.is_a? WillPaginate::Collection
|
94
|
+
array.current_page.should == 1
|
95
|
+
array.per_page.should == 2
|
96
|
+
end
|
97
|
+
|
98
|
+
it "doesn't have a problem assigning has-one-through relationship" do
|
99
|
+
human = Human.create :name => "Mislav"
|
100
|
+
human.pet = Animal.first
|
101
|
+
end
|
102
|
+
|
83
103
|
end if datamapper_loaded
|
@@ -19,9 +19,34 @@ class Animal
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
class Ownership
|
23
|
+
include DataMapper::Resource
|
24
|
+
|
25
|
+
belongs_to :animal, :key => true
|
26
|
+
belongs_to :human, :key => true
|
27
|
+
|
28
|
+
def self.setup
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class Human
|
33
|
+
include DataMapper::Resource
|
34
|
+
|
35
|
+
property :id, Serial
|
36
|
+
property :name, String
|
37
|
+
|
38
|
+
has n, :ownerships
|
39
|
+
has 1, :pet, :model => 'Animal', :through => :ownerships, :via => :animal
|
40
|
+
|
41
|
+
def self.setup
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
22
45
|
# Load fixtures
|
23
|
-
Animal.
|
24
|
-
|
46
|
+
[Animal, Ownership, Human].each do |klass|
|
47
|
+
klass.auto_migrate!
|
48
|
+
klass.setup
|
49
|
+
end
|
25
50
|
|
26
51
|
if 'irb' == $0
|
27
52
|
DataMapper.logger.set_log($stdout, :debug)
|
metadata
CHANGED
@@ -1,28 +1,26 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: will_paginate
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.0.3
|
4
5
|
prerelease:
|
5
|
-
version: 3.0.2
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
8
|
-
-
|
7
|
+
authors:
|
8
|
+
- Mislav Marohnić
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
date: 2011-09-27 00:00:00 Z
|
12
|
+
date: 2012-01-31 00:00:00.000000000 Z
|
14
13
|
dependencies: []
|
15
|
-
|
16
|
-
|
14
|
+
description: will_paginate provides a simple API for performing paginated queries
|
15
|
+
with Active Record, DataMapper and Sequel, and includes helpers for rendering pagination
|
16
|
+
links in Rails, Sinatra and Merb web apps.
|
17
17
|
email: mislav.marohnic@gmail.com
|
18
18
|
executables: []
|
19
|
-
|
20
19
|
extensions: []
|
21
|
-
|
22
|
-
extra_rdoc_files:
|
20
|
+
extra_rdoc_files:
|
23
21
|
- README.md
|
24
22
|
- LICENSE
|
25
|
-
files:
|
23
|
+
files:
|
26
24
|
- Rakefile
|
27
25
|
- lib/will_paginate/active_record.rb
|
28
26
|
- lib/will_paginate/array.rb
|
@@ -78,32 +76,30 @@ files:
|
|
78
76
|
- LICENSE
|
79
77
|
homepage: https://github.com/mislav/will_paginate/wiki
|
80
78
|
licenses: []
|
81
|
-
|
82
79
|
post_install_message:
|
83
|
-
rdoc_options:
|
80
|
+
rdoc_options:
|
84
81
|
- --main
|
85
82
|
- README.md
|
86
83
|
- --charset=UTF-8
|
87
|
-
require_paths:
|
84
|
+
require_paths:
|
88
85
|
- lib
|
89
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
87
|
none: false
|
91
|
-
requirements:
|
92
|
-
- -
|
93
|
-
- !ruby/object:Gem::Version
|
94
|
-
version:
|
95
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
93
|
none: false
|
97
|
-
requirements:
|
98
|
-
- -
|
99
|
-
- !ruby/object:Gem::Version
|
100
|
-
version:
|
94
|
+
requirements:
|
95
|
+
- - ! '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
101
98
|
requirements: []
|
102
|
-
|
103
99
|
rubyforge_project:
|
104
|
-
rubygems_version: 1.8.
|
100
|
+
rubygems_version: 1.8.12
|
105
101
|
signing_key:
|
106
102
|
specification_version: 3
|
107
103
|
summary: Pagination plugin for web frameworks and other apps
|
108
104
|
test_files: []
|
109
|
-
|
105
|
+
has_rdoc:
|