will_paginate 3.1.0 → 3.1.1

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
  SHA1:
3
- metadata.gz: b3445d24047dd419909e314bc5f1b9eb3fdb7f73
4
- data.tar.gz: 2e6ce5705bc95b523bdd8a7ffa9d8e0b35acc36f
3
+ metadata.gz: 37738a4f9afbe87bcb4061f1e0336498f38ddf49
4
+ data.tar.gz: 61784364ffb2e3fc1719b85fe0e7ee8f92de8a9a
5
5
  SHA512:
6
- metadata.gz: bdc9b0d1f20379dc1df3dc503796834b329976c90a63f4e0f14b77152aef8721bea240f850d0abc0c0171a3e1ad10d5c88a354136e47d4bb933b29a205311d7d
7
- data.tar.gz: c35edfea8e81e70fef045d9f1c3c32bea89723a1bd74a6c2edb438c62fc54c3356eb4704329c42b35760178c71a505ee0d86c0109a6f7cd3fdacd5276af4eb74
6
+ metadata.gz: dfc4458d9ab67b9d059c5028d8346d28be729bc85c81df5b5d4a23e34f71075ea5ca9a3ccc98950ee82302413101fb3b259ed5f4180e43e4f5952fd0286c05e0
7
+ data.tar.gz: b4efefc99c7aff85f172eead0b2356f90eab50c4502002425bb198abb187c0ed833aa3dd1f7da36a8dd0a6bf4cf2a62d5339f090ea5f7ad20a198c14ea71a731
data/README.md CHANGED
@@ -6,7 +6,7 @@ Installation:
6
6
 
7
7
  ``` ruby
8
8
  ## Gemfile for Rails 3+, Sinatra, and Merb
9
- gem 'will_paginate', '~> 3.0.6'
9
+ gem 'will_paginate', '~> 3.1.0'
10
10
  ```
11
11
 
12
12
  See [installation instructions][install] on the wiki for more info.
@@ -51,8 +51,8 @@ module WillPaginate
51
51
  end
52
52
 
53
53
  # fix for Rails 3.0
54
- def find_last
55
- if !loaded? and offset_value || limit_value
54
+ def find_last(*args)
55
+ if !loaded? && args.empty? && (offset_value || limit_value)
56
56
  @last ||= to_a.last
57
57
  else
58
58
  super
@@ -2,7 +2,7 @@ module WillPaginate #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 3
4
4
  MINOR = 1
5
- TINY = 0
5
+ TINY = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -99,6 +99,8 @@ module WillPaginate
99
99
  class LinkRenderer < ViewHelpers::LinkRenderer
100
100
  protected
101
101
 
102
+ GET_PARAMS_BLACKLIST = [:script_name]
103
+
102
104
  def default_url_params
103
105
  {}
104
106
  end
@@ -118,7 +120,7 @@ module WillPaginate
118
120
 
119
121
  def merge_get_params(url_params)
120
122
  if @template.respond_to? :request and @template.request and @template.request.get?
121
- symbolized_update(url_params, @template.params)
123
+ symbolized_update(url_params, @template.params, GET_PARAMS_BLACKLIST)
122
124
  end
123
125
  url_params
124
126
  end
@@ -114,11 +114,12 @@ module WillPaginate
114
114
  end
115
115
  end
116
116
 
117
- def symbolized_update(target, other)
117
+ def symbolized_update(target, other, blacklist = nil)
118
118
  other.each do |key, value|
119
119
  key = key.to_sym
120
120
  existing = target[key]
121
-
121
+ next if blacklist && blacklist.include?(key)
122
+
122
123
  if value.is_a?(Hash) and (existing.is_a?(Hash) or existing.nil?)
123
124
  symbolized_update(existing || (target[key] = {}), value)
124
125
  else
data/spec/database.yml CHANGED
@@ -3,23 +3,27 @@ sqlite3:
3
3
  adapter: sqlite3
4
4
  timeout: 500
5
5
 
6
- mysql:
6
+ mysql: &mysql
7
7
  adapter: mysql
8
8
  database: will_paginate
9
9
  username:
10
10
  encoding: utf8
11
- socket: <%= ENV["BOXEN_MYSQL_SOCKET"] %>
11
+ <% if File.exist?("/var/run/mysql5/mysqld.sock") %>
12
+ host: localhost
13
+ socket: /var/run/mysql5/mysqld.sock
14
+ <% elsif File.exist? "/tmp/mysql.sock" %>
15
+ host: localhost
16
+ socket: /tmp/mysql.sock
17
+ <% else %>
18
+ host: 127.0.0.1
19
+ <% end %>
12
20
 
13
21
  mysql2:
22
+ <<: *mysql
14
23
  adapter: mysql2
15
- database: will_paginate
16
- username:
17
- encoding: utf8
18
- socket: <%= ENV["BOXEN_MYSQL_SOCKET"] %>
19
24
 
20
25
  postgres:
21
26
  adapter: postgresql
22
27
  database: will_paginate
23
28
  username: <%= "postgres" if ENV["TRAVIS"] %>
24
29
  min_messages: warning
25
- port: <%= ENV["BOXEN_POSTGRESQL_PORT"] %>
@@ -201,6 +201,13 @@ describe WillPaginate::ActionView do
201
201
  assert_no_links_match /99/
202
202
  assert_no_links_match /ftp/
203
203
  end
204
+
205
+ it "doesn't allow tampering with script_name" do
206
+ request.params :script_name => 'p0wned'
207
+ paginate
208
+ assert_links_match %r{^/foo/bar}
209
+ assert_no_links_match /p0wned/
210
+ end
204
211
 
205
212
  it "should not preserve parameters on POST" do
206
213
  request.post
@@ -250,7 +257,7 @@ describe WillPaginate::ActionView do
250
257
  end
251
258
 
252
259
  it "should paginate with custom route page parameter" do
253
- request.symbolized_path_parameters.update :controller => 'dummy', :action => nil
260
+ request.symbolized_path_parameters.update :controller => 'dummy', :action => 'index'
254
261
  paginate :per_page => 2 do
255
262
  assert_select 'a[href]', 6 do |links|
256
263
  assert_links_match %r{/page/(\d+)$}, links, [2, 3, 4, 5, 6, 2]
@@ -268,7 +275,7 @@ describe WillPaginate::ActionView do
268
275
  end
269
276
 
270
277
  it "should paginate with custom route and first page number implicit" do
271
- request.symbolized_path_parameters.update :controller => 'ibocorp', :action => nil
278
+ request.symbolized_path_parameters.update :controller => 'ibocorp', :action => 'index'
272
279
  paginate :page => 2, :per_page => 2 do
273
280
  assert_select 'a[href]', 7 do |links|
274
281
  assert_links_match %r{/ibocorp(?:/(\d+))?$}, links, [nil, nil, 3, 4, 5, 6, 3]
@@ -143,4 +143,4 @@ module HTML
143
143
  childless?? '' : super
144
144
  end
145
145
  end
146
- end
146
+ end if defined?(HTML)
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.1.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mislav Marohnić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-03 00:00:00.000000000 Z
11
+ date: 2016-09-20 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