will_paginate 2.3.15 → 2.3.16

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of will_paginate might be problematic. Click here for more details.

@@ -2,6 +2,10 @@ require 'active_record'
2
2
  require 'active_record/version'
3
3
  require 'active_record/fixtures'
4
4
 
5
+ # prevent psych kicking in on 1.9 and interpreting
6
+ # local timestamps in fixtures as UTC
7
+ YAML::ENGINE.yamler = 'syck' if defined? YAML::ENGINE
8
+
5
9
  class ActiveRecordTestConnector
6
10
  cattr_accessor :able_to_connect
7
11
  cattr_accessor :connected
@@ -42,10 +46,9 @@ class ActiveRecordTestConnector
42
46
  ActiveRecord::Base.logger = Logger.new(STDOUT) if $0 == 'irb'
43
47
  puts "using #{configuration['adapter']} adapter" unless ENV['DB'].blank?
44
48
 
45
- gem 'sqlite3-ruby' if 'sqlite3' == db
46
-
47
49
  ActiveRecord::Base.establish_connection(configuration)
48
50
  ActiveRecord::Base.configurations = { db => configuration }
51
+ ActiveRecord::Base.default_timezone = :local if ActiveRecord::Base.respond_to? :default_timezone
49
52
  prepare ActiveRecord::Base.connection
50
53
 
51
54
  unless Object.const_defined?(:QUOTED_TYPE)
@@ -62,11 +65,18 @@ class ActiveRecordTestConnector
62
65
 
63
66
  def self.prepare(conn)
64
67
  class << conn
65
- IGNORED_SQL = [/^PRAGMA/, /^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/, /^SELECT @@ROWCOUNT/, /^SHOW FIELDS /]
68
+ IGNORED_SQL = /
69
+ ^(
70
+ PRAGMA | SHOW\ max_identifier_length |
71
+ SELECT\ (currval|CAST|@@IDENTITY|@@ROWCOUNT) |
72
+ SHOW\ (FIELDS|TABLES)
73
+ )\b |
74
+ \bFROM\ (sqlite_master|pg_tables|pg_attribute)\b
75
+ /x
66
76
 
67
77
  def execute_with_counting(sql, name = nil, &block)
68
78
  $query_count ||= 0
69
- $query_count += 1 unless IGNORED_SQL.any? { |r| sql =~ r }
79
+ $query_count += 1 unless sql =~ IGNORED_SQL
70
80
  execute_without_counting(sql, name, &block)
71
81
  end
72
82
 
@@ -1,4 +1,5 @@
1
- require 'boot'
1
+ require 'bundler'
2
+ Bundler.setup
2
3
  require 'lib/activerecord_test_connector'
3
4
 
4
5
  # setup the connection
@@ -111,6 +111,13 @@ class WillPaginate::ViewTestCase < Test::Unit::TestCase
111
111
  end
112
112
  end
113
113
  end
114
+
115
+ private
116
+
117
+ def load_fixtures
118
+ # fix for Rails 1.2
119
+ @loaded_fixtures = {}
120
+ end
114
121
  end
115
122
 
116
123
  class DummyRequest
data/test/view_test.rb CHANGED
@@ -196,7 +196,7 @@ class ViewTest < WillPaginate::ViewTestCase
196
196
  def test_page_entries_info_with_longer_class_name
197
197
  @template = '<%= page_entries_info collection %>'
198
198
  collection = ('a'..'z').to_a.paginate
199
- collection.first.stubs(:class).returns(mock('class', :name => 'ProjectType'))
199
+ collection.first.stubs(:class).returns(mock('class', :to_s => 'ProjectType'))
200
200
 
201
201
  paginate collection
202
202
  assert @html_result.index('project types'), "expected <#{@html_result.inspect}> to mention 'project types'"
@@ -207,7 +207,7 @@ class ViewTest < WillPaginate::ViewTestCase
207
207
  @template = '<%= page_entries_info collection %>'
208
208
 
209
209
  paginate(('a'..'d').to_a.paginate(:page => 1, :per_page => 5))
210
- assert_equal %{Displaying <b>all 4</b> strings}, @html_result
210
+ assert_equal %{Displaying <b>all&nbsp;4</b> strings}, @html_result
211
211
 
212
212
  paginate(['a'].paginate(:page => 1, :per_page => 5))
213
213
  assert_equal %{Displaying <b>1</b> string}, @html_result
@@ -217,7 +217,7 @@ class ViewTest < WillPaginate::ViewTestCase
217
217
  end
218
218
 
219
219
  def test_page_entries_info_with_custom_entry_name
220
- @template = '<%= page_entries_info collection, :entry_name => "author" %>'
220
+ @template = '<%= page_entries_info collection, :model => "author" %>'
221
221
 
222
222
  entries = (1..20).to_a
223
223
 
@@ -225,7 +225,7 @@ class ViewTest < WillPaginate::ViewTestCase
225
225
  assert_equal %{Displaying authors <b>1&nbsp;-&nbsp;5</b> of <b>20</b> in total}, @html_result
226
226
 
227
227
  paginate(entries.paginate(:page => 1, :per_page => 20))
228
- assert_equal %{Displaying <b>all 20</b> authors}, @html_result
228
+ assert_equal %{Displaying <b>all&nbsp;20</b> authors}, @html_result
229
229
 
230
230
  paginate(['a'].paginate(:page => 1, :per_page => 5))
231
231
  assert_equal %{Displaying <b>1</b> author}, @html_result
@@ -283,7 +283,7 @@ class ViewTest < WillPaginate::ViewTestCase
283
283
  renderer = WillPaginate::LinkRenderer.new
284
284
 
285
285
  paginate({ :page => 1 }, :renderer=>renderer)
286
- assert_links_match %r[/foo/@tag\?page=\d]
286
+ assert_links_match %r[/foo/(?:@|%40)tag\?page=\d]
287
287
  end
288
288
 
289
289
  def test_complex_custom_page_param
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: will_paginate
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
5
- prerelease: false
6
- segments:
7
- - 2
8
- - 3
9
- - 15
10
- version: 2.3.15
4
+ prerelease:
5
+ version: 2.3.16
11
6
  platform: ruby
12
7
  authors:
13
8
  - "Mislav Marohni\xC4\x87"
@@ -16,18 +11,17 @@ autorequire:
16
11
  bindir: bin
17
12
  cert_chain: []
18
13
 
19
- date: 2010-09-09 00:00:00 +02:00
20
- default_executable:
14
+ date: 2011-08-09 00:00:00 Z
21
15
  dependencies: []
22
16
 
23
- description: The will_paginate library provides a simple, yet powerful and extensible API for ActiveRecord pagination and rendering of pagination links in ActionView templates.
17
+ description: will_paginate provides a simple API for Active Record pagination and rendering of pagination links in Rails templates.
24
18
  email: mislav.marohnic@gmail.com
25
19
  executables: []
26
20
 
27
21
  extensions: []
28
22
 
29
23
  extra_rdoc_files:
30
- - README.rdoc
24
+ - README.md
31
25
  - LICENSE
32
26
  - CHANGELOG.rdoc
33
27
  files:
@@ -36,12 +30,15 @@ files:
36
30
  - lib/will_paginate/collection.rb
37
31
  - lib/will_paginate/core_ext.rb
38
32
  - lib/will_paginate/finder.rb
33
+ - lib/will_paginate/i18n.rb
34
+ - lib/will_paginate/locale/en.yml
39
35
  - lib/will_paginate/named_scope.rb
40
36
  - lib/will_paginate/named_scope_patch.rb
37
+ - lib/will_paginate/per_page.rb
41
38
  - lib/will_paginate/version.rb
42
39
  - lib/will_paginate/view_helpers.rb
43
40
  - lib/will_paginate.rb
44
- - test/boot.rb
41
+ - test/ci.rb
45
42
  - test/collection_test.rb
46
43
  - test/console
47
44
  - test/database.yml
@@ -58,24 +55,30 @@ files:
58
55
  - test/fixtures/topics.yml
59
56
  - test/fixtures/user.rb
60
57
  - test/fixtures/users.yml
58
+ - test/gemfiles/Gemfile.1.2
59
+ - test/gemfiles/Gemfile.1.2.lock
60
+ - test/gemfiles/Gemfile.2.0
61
+ - test/gemfiles/Gemfile.2.0.lock
62
+ - test/gemfiles/Gemfile.2.1
63
+ - test/gemfiles/Gemfile.2.1.lock
64
+ - test/gemfiles/Gemfile.2.2
65
+ - test/gemfiles/Gemfile.2.2.lock
61
66
  - test/helper.rb
62
67
  - test/lib/activerecord_test_case.rb
63
68
  - test/lib/activerecord_test_connector.rb
64
69
  - test/lib/load_fixtures.rb
65
70
  - test/lib/view_test_process.rb
66
- - test/tasks.rake
67
71
  - test/view_test.rb
68
- - README.rdoc
72
+ - README.md
69
73
  - LICENSE
70
74
  - CHANGELOG.rdoc
71
- has_rdoc: true
72
- homepage: http://github.com/mislav/will_paginate/wikis
75
+ homepage: https://github.com/mislav/will_paginate/wiki
73
76
  licenses: []
74
77
 
75
78
  post_install_message:
76
79
  rdoc_options:
77
80
  - --main
78
- - README.rdoc
81
+ - README.md
79
82
  - --charset=UTF-8
80
83
  require_paths:
81
84
  - lib
@@ -84,25 +87,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
84
87
  requirements:
85
88
  - - ">="
86
89
  - !ruby/object:Gem::Version
87
- hash: 3
88
- segments:
89
- - 0
90
90
  version: "0"
91
91
  required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  none: false
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- hash: 3
97
- segments:
98
- - 0
99
96
  version: "0"
100
97
  requirements: []
101
98
 
102
99
  rubyforge_project:
103
- rubygems_version: 1.3.7
100
+ rubygems_version: 1.8.5
104
101
  signing_key:
105
102
  specification_version: 3
106
- summary: Pagination for Rails
103
+ summary: Easy pagination for Rails
107
104
  test_files: []
108
105
 
data/README.rdoc DELETED
@@ -1,107 +0,0 @@
1
- = WillPaginate
2
-
3
- Pagination is just limiting the number of records displayed. Why should you let
4
- it get in your way while developing, then? This plugin makes magic happen. Did
5
- you ever want to be able to do just this on a model:
6
-
7
- Post.paginate :page => 1, :order => 'created_at DESC'
8
-
9
- ... and then render the page links with a single view helper? Well, now you
10
- can.
11
-
12
- Some resources to get you started:
13
-
14
- * {Installation instructions}[http://github.com/mislav/will_paginate/wikis/installation]
15
- on {the wiki}[http://github.com/mislav/will_paginate/wikis]
16
- * Your mind reels with questions? Join our
17
- {Google group}[http://groups.google.com/group/will_paginate].
18
- * {How to report bugs}[http://github.com/mislav/will_paginate/wikis/report-bugs]
19
-
20
-
21
- == Example usage
22
-
23
- Use a paginate finder in the controller:
24
-
25
- @posts = Post.paginate_by_board_id @board.id, :page => params[:page], :order => 'updated_at DESC'
26
-
27
- Yeah, +paginate+ works just like +find+ -- it just doesn't fetch all the
28
- records. Don't forget to tell it which page you want, or it will complain!
29
- Read more on WillPaginate::Finder::ClassMethods.
30
-
31
- Render the posts in your view like you would normally do. When you need to render
32
- pagination, just stick this in:
33
-
34
- <%= will_paginate @posts %>
35
-
36
- You're done. (You can find the option list at WillPaginate::ViewHelpers.)
37
-
38
- How does it know how much items to fetch per page? It asks your model by calling
39
- its <tt>per_page</tt> class method. You can define it like this:
40
-
41
- class Post < ActiveRecord::Base
42
- cattr_reader :per_page
43
- @@per_page = 50
44
- end
45
-
46
- ... or like this:
47
-
48
- class Post < ActiveRecord::Base
49
- def self.per_page
50
- 50
51
- end
52
- end
53
-
54
- ... or don't worry about it at all. WillPaginate defines it to be <b>30</b> by default.
55
- But you can always specify the count explicitly when calling +paginate+:
56
-
57
- @posts = Post.paginate :page => params[:page], :per_page => 50
58
-
59
- The +paginate+ finder wraps the original finder and returns your resultset that now has
60
- some new properties. You can use the collection as you would with any ActiveRecord
61
- resultset. WillPaginate view helpers also need that object to be able to render pagination:
62
-
63
- <ol>
64
- <% for post in @posts -%>
65
- <li>Render `post` in some nice way.</li>
66
- <% end -%>
67
- </ol>
68
-
69
- <p>Now let's render us some pagination!</p>
70
- <%= will_paginate @posts %>
71
-
72
- More detailed documentation:
73
-
74
- * WillPaginate::Finder::ClassMethods for pagination on your models;
75
- * WillPaginate::ViewHelpers for your views.
76
-
77
-
78
- == Authors and credits
79
-
80
- Authors:: Mislav Marohnić, PJ Hyett
81
- Original announcement:: http://errtheblog.com/post/929
82
- Original PHP source:: http://www.strangerstudios.com/sandbox/pagination/diggstyle.php
83
-
84
- All these people helped making will_paginate what it is now with their code
85
- contributions or just simply awesome ideas:
86
-
87
- Chris Wanstrath, Dr. Nic Williams, K. Adam Christensen, Mike Garey, Bence
88
- Golda, Matt Aimonetti, Charles Brian Quinn, Desi McAdam, James Coglan, Matijs
89
- van Zuijlen, Maria, Brendan Ribera, Todd Willey, Bryan Helmkamp, Jan Berkel,
90
- Lourens Naudé, Rick Olson, Russell Norris, Piotr Usewicz, Chris Eppstein,
91
- Denis Barushev, Ben Pickles.
92
-
93
-
94
- == Usable pagination in the UI
95
-
96
- There are some CSS styles to get you started in the "examples/" directory. They
97
- are {showcased online here}[http://mislav.uniqpath.com/will_paginate/].
98
-
99
- More reading about pagination as design pattern:
100
-
101
- * {Pagination 101}[http://kurafire.net/log/archive/2007/06/22/pagination-101]
102
- * {Pagination gallery}[http://www.smashingmagazine.com/2007/11/16/pagination-gallery-examples-and-good-practices/]
103
- * {Pagination on Yahoo Design Pattern Library}[http://developer.yahoo.com/ypatterns/parent.php?pattern=pagination]
104
-
105
- Want to discuss, request features, ask questions? Join the
106
- {Google group}[http://groups.google.com/group/will_paginate].
107
-
data/test/boot.rb DELETED
@@ -1,21 +0,0 @@
1
- plugin_root = File.join(File.dirname(__FILE__), '..')
2
- version = ENV['RAILS_VERSION']
3
- version = nil if version and version == ""
4
-
5
- # first look for a symlink to a copy of the framework
6
- if !version and framework_root = ["#{plugin_root}/rails", "#{plugin_root}/../../rails"].find { |p| File.directory? p }
7
- puts "found framework root: #{framework_root}"
8
- # this allows for a plugin to be tested outside of an app and without Rails gems
9
- $:.unshift "#{framework_root}/activesupport/lib", "#{framework_root}/activerecord/lib", "#{framework_root}/actionpack/lib"
10
- else
11
- # simply use installed gems if available
12
- puts "using Rails#{version ? ' ' + version : nil} gems"
13
- require 'rubygems'
14
-
15
- if version
16
- gem 'rails', version
17
- else
18
- gem 'actionpack', '< 3.0.0.a'
19
- gem 'activerecord', '< 3.0.0.a'
20
- end
21
- end
data/test/tasks.rake DELETED
@@ -1,59 +0,0 @@
1
- require 'rake/testtask'
2
-
3
- desc 'Test the will_paginate plugin.'
4
- Rake::TestTask.new(:test) do |t|
5
- t.pattern = 'test/**/*_test.rb'
6
- t.verbose = true
7
- t.libs << 'test'
8
- end
9
-
10
- # I want to specify environment variables at call time
11
- class EnvTestTask < Rake::TestTask
12
- attr_accessor :env
13
-
14
- def ruby(*args)
15
- env.each { |key, value| ENV[key] = value } if env
16
- super
17
- env.keys.each { |key| ENV.delete key } if env
18
- end
19
- end
20
-
21
- for configuration in %w( sqlite3 mysql postgres )
22
- EnvTestTask.new("test_#{configuration}") do |t|
23
- t.pattern = 'test/finder_test.rb'
24
- t.verbose = true
25
- t.env = { 'DB' => configuration }
26
- t.libs << 'test'
27
- end
28
- end
29
-
30
- task :test_databases => %w(test_mysql test_sqlite3 test_postgres)
31
-
32
- desc %{Test everything on SQLite3, MySQL and PostgreSQL}
33
- task :test_full => %w(test test_mysql test_postgres)
34
-
35
- desc %{Test everything with Rails 2.1.x, 2.0.x & 1.2.x gems}
36
- task :test_all do
37
- all = Rake::Task['test_full']
38
- versions = %w(2.3.2 2.2.2 2.1.0 2.0.4 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
47
- %w( test_full test test_mysql test_postgres ).each do |name|
48
- Rake::Task[name].instance_variable_set '@already_invoked', false
49
- end
50
- end
51
-
52
- task :rcov do
53
- excludes = %w( lib/will_paginate/named_scope*
54
- lib/will_paginate/core_ext.rb
55
- lib/will_paginate.rb
56
- rails* )
57
-
58
- system %[rcov -Itest:lib test/*.rb -x #{excludes.join(',')}]
59
- end