will_paginate 3.1.1 → 3.1.5

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: 37738a4f9afbe87bcb4061f1e0336498f38ddf49
4
- data.tar.gz: 61784364ffb2e3fc1719b85fe0e7ee8f92de8a9a
3
+ metadata.gz: 5b9c92a0ce3f9e697334ea1bf11c0b57bdfd9fe2
4
+ data.tar.gz: b2794b2de86ceaa34f86d06f2c1952484b5409f9
5
5
  SHA512:
6
- metadata.gz: dfc4458d9ab67b9d059c5028d8346d28be729bc85c81df5b5d4a23e34f71075ea5ca9a3ccc98950ee82302413101fb3b259ed5f4180e43e4f5952fd0286c05e0
7
- data.tar.gz: b4efefc99c7aff85f172eead0b2356f90eab50c4502002425bb198abb187c0ed833aa3dd1f7da36a8dd0a6bf4cf2a62d5339f090ea5f7ad20a198c14ea71a731
6
+ metadata.gz: fe7a7e48c35bda6cd6648f5243f3992ebe576f586afd5d140066fa05ecdd83862681245f44e554f5483e5dc4fe9f957e3b84b6208cc91a8e1dd1804c8593a49b
7
+ data.tar.gz: 5c388ced4fd0b8ad3da2ce6c5e9b2323b4cff1b950fdf3b35cc6e148b1e12509e8b6c0b83156b483d1a732ce4fe2497a4c09553b2650775cc922803699bf4347
@@ -18,8 +18,6 @@ module WillPaginate
18
18
  require 'will_paginate/view_helpers/action_view'
19
19
  end
20
20
 
21
- self.class.add_locale_path config
22
-
23
21
  # early access to ViewHelpers.pagination_options
24
22
  require 'will_paginate/view_helpers'
25
23
  end
@@ -31,10 +29,6 @@ module WillPaginate
31
29
  ActionController::Base.extend ControllerRescuePatch
32
30
  end
33
31
 
34
- def self.add_locale_path(config)
35
- config.i18n.load_path.unshift(*WillPaginate::I18n.load_path)
36
- end
37
-
38
32
  # Extending the exception handler middleware so it properly detects
39
33
  # WillPaginate::InvalidPage regardless of it being a tag module.
40
34
  module ShowExceptionsPatch
@@ -44,9 +38,15 @@ module WillPaginate
44
38
  alias_method :status_code, :status_code_with_paginate
45
39
  end
46
40
  def status_code_with_paginate(exception = @exception)
47
- if exception.is_a?(WillPaginate::InvalidPage) or
48
- (exception.respond_to?(:original_exception) &&
49
- exception.original_exception.is_a?(WillPaginate::InvalidPage))
41
+ actual_exception = if exception.respond_to?(:cause)
42
+ exception.cause
43
+ elsif exception.respond_to?(:original_exception)
44
+ exception.original_exception
45
+ else
46
+ exception
47
+ end
48
+
49
+ if actual_exception.is_a?(WillPaginate::InvalidPage)
50
50
  Rack::Utils.status_code(:not_found)
51
51
  else
52
52
  original_method = method(:status_code_without_paginate)
@@ -69,3 +69,7 @@ module WillPaginate
69
69
  end
70
70
  end
71
71
  end
72
+
73
+ ActiveSupport.on_load :i18n do
74
+ I18n.load_path.concat(WillPaginate::I18n.load_path)
75
+ end
@@ -2,7 +2,7 @@ module WillPaginate #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 3
4
4
  MINOR = 1
5
- TINY = 1
5
+ TINY = 5
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -99,7 +99,7 @@ module WillPaginate
99
99
  class LinkRenderer < ViewHelpers::LinkRenderer
100
100
  protected
101
101
 
102
- GET_PARAMS_BLACKLIST = [:script_name]
102
+ GET_PARAMS_BLACKLIST = [:script_name, :original_script_name]
103
103
 
104
104
  def default_url_params
105
105
  {}
@@ -41,10 +41,10 @@ module WillPaginate
41
41
  protected
42
42
 
43
43
  def page_number(page)
44
- unless page == current_page
45
- link(page, page, :rel => rel_value(page))
46
- else
44
+ if page == current_page
47
45
  tag(:em, page, :class => 'current')
46
+ else
47
+ link(page, page, :rel => rel_value(page))
48
48
  end
49
49
  end
50
50
 
@@ -108,19 +108,18 @@ module WillPaginate
108
108
 
109
109
  def rel_value(page)
110
110
  case page
111
- when @collection.current_page - 1; 'prev' + (page == 1 ? ' start' : '')
111
+ when @collection.current_page - 1; 'prev'
112
112
  when @collection.current_page + 1; 'next'
113
- when 1; 'start'
114
113
  end
115
114
  end
116
115
 
117
116
  def symbolized_update(target, other, blacklist = nil)
118
- other.each do |key, value|
117
+ other.each_pair do |key, value|
119
118
  key = key.to_sym
120
119
  existing = target[key]
121
120
  next if blacklist && blacklist.include?(key)
122
121
 
123
- if value.is_a?(Hash) and (existing.is_a?(Hash) or existing.nil?)
122
+ if value.respond_to?(:each_pair) and (existing.is_a?(Hash) or existing.nil?)
124
123
  symbolized_update(existing || (target[key] = {}), value)
125
124
  else
126
125
  target[key] = value
@@ -30,7 +30,7 @@ module WillPaginate
30
30
  window_from = current_page - inner_window
31
31
  window_to = current_page + inner_window
32
32
 
33
- # adjust lower or upper limit if other is out of bounds
33
+ # adjust lower or upper limit if either is out of bounds
34
34
  if window_to > total_pages
35
35
  window_from -= window_to - total_pages
36
36
  window_to = total_pages
@@ -80,9 +80,9 @@ describe WillPaginate::ActionView do
80
80
  validate_page_numbers [1,1,3,3], elements
81
81
  # test rel attribute values:
82
82
  text(elements[0]).should == 'Prev'
83
- elements[0]['rel'].should == 'prev start'
83
+ elements[0]['rel'].should == 'prev'
84
84
  text(elements[1]).should == '1'
85
- elements[1]['rel'].should == 'prev start'
85
+ elements[1]['rel'].should == 'prev'
86
86
  text(elements[3]).should == 'Next'
87
87
  elements[3]['rel'].should == 'next'
88
88
  end
@@ -203,7 +203,7 @@ describe WillPaginate::ActionView do
203
203
  end
204
204
 
205
205
  it "doesn't allow tampering with script_name" do
206
- request.params :script_name => 'p0wned'
206
+ request.params :script_name => 'p0wned', :original_script_name => 'p0wned'
207
207
  paginate
208
208
  assert_links_match %r{^/foo/bar}
209
209
  assert_no_links_match /p0wned/
@@ -416,7 +416,7 @@ class DummyRequest
416
416
  def initialize(controller)
417
417
  @controller = controller
418
418
  @get = true
419
- @params = {}
419
+ @params = {}.with_indifferent_access
420
420
  @symbolized_path_parameters = { :controller => 'foo', :action => 'bar' }
421
421
  end
422
422
 
@@ -442,7 +442,11 @@ class DummyRequest
442
442
 
443
443
  def params(more = nil)
444
444
  @params.update(more) if more
445
- @params
445
+ if defined?(ActionController::Parameters)
446
+ ActionController::Parameters.new(@params)
447
+ else
448
+ @params
449
+ end
446
450
  end
447
451
 
448
452
  def host_with_port
@@ -458,3 +462,7 @@ class DummyRequest
458
462
  'http:'
459
463
  end
460
464
  end
465
+
466
+ if defined?(ActionController::Parameters)
467
+ ActionController::Parameters.permit_all_parameters = false
468
+ 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.1.1
4
+ version: 3.1.5
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-09-20 00:00:00.000000000 Z
11
+ date: 2016-10-15 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