[DRE-commits] [ruby-will-paginate] 01/02: Imported Upstream version 3.1.5

Abhijith PA abhijithpa-guest at moszumanska.debian.org
Sun Nov 13 06:52:05 UTC 2016


This is an automated email from the git hooks/post-receive script.

abhijithpa-guest pushed a commit to branch master
in repository ruby-will-paginate.

commit eaa74fd8a39722ec29ed72175234003d00c836fb
Author: Abhijith PA <abhijith at openmailbox.org>
Date:   Sun Nov 13 12:19:54 2016 +0530

    Imported Upstream version 3.1.5
---
 README.md                                          |  2 +-
 lib/will_paginate/active_record.rb                 |  4 ++--
 lib/will_paginate/railtie.rb                       | 22 ++++++++++--------
 lib/will_paginate/version.rb                       |  2 +-
 lib/will_paginate/view_helpers/action_view.rb      |  4 +++-
 lib/will_paginate/view_helpers/link_renderer.rb    | 18 +++++++--------
 .../view_helpers/link_renderer_base.rb             |  2 +-
 metadata.yml                                       |  4 ++--
 spec/database.yml                                  | 18 +++++++++------
 spec/view_helpers/action_view_spec.rb              | 27 +++++++++++++++++-----
 spec/view_helpers/view_example_group.rb            |  2 +-
 11 files changed, 65 insertions(+), 40 deletions(-)

diff --git a/README.md b/README.md
index 13a0972..42838c3 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@ Installation:
 
 ``` ruby
 ## Gemfile for Rails 3+, Sinatra, and Merb
-gem 'will_paginate', '~> 3.0.6'
+gem 'will_paginate', '~> 3.1.0'
 ```
 
 See [installation instructions][install] on the wiki for more info.
diff --git a/lib/will_paginate/active_record.rb b/lib/will_paginate/active_record.rb
index 384d306..40d127b 100644
--- a/lib/will_paginate/active_record.rb
+++ b/lib/will_paginate/active_record.rb
@@ -51,8 +51,8 @@ module WillPaginate
       end
 
       # fix for Rails 3.0
-      def find_last
-        if !loaded? and offset_value || limit_value
+      def find_last(*args)
+        if !loaded? && args.empty? && (offset_value || limit_value)
           @last ||= to_a.last
         else
           super
diff --git a/lib/will_paginate/railtie.rb b/lib/will_paginate/railtie.rb
index bed794f..99ddbbd 100644
--- a/lib/will_paginate/railtie.rb
+++ b/lib/will_paginate/railtie.rb
@@ -18,8 +18,6 @@ module WillPaginate
         require 'will_paginate/view_helpers/action_view'
       end
 
-      self.class.add_locale_path config
-
       # early access to ViewHelpers.pagination_options
       require 'will_paginate/view_helpers'
     end
@@ -31,10 +29,6 @@ module WillPaginate
       ActionController::Base.extend ControllerRescuePatch
     end
 
-    def self.add_locale_path(config)
-      config.i18n.load_path.unshift(*WillPaginate::I18n.load_path)
-    end
-
     # Extending the exception handler middleware so it properly detects
     # WillPaginate::InvalidPage regardless of it being a tag module.
     module ShowExceptionsPatch
@@ -44,9 +38,15 @@ module WillPaginate
         alias_method :status_code, :status_code_with_paginate
       end
       def status_code_with_paginate(exception = @exception)
-        if exception.is_a?(WillPaginate::InvalidPage) or
-            (exception.respond_to?(:original_exception) &&
-              exception.original_exception.is_a?(WillPaginate::InvalidPage))
+        actual_exception = if exception.respond_to?(:cause)
+          exception.cause
+        elsif exception.respond_to?(:original_exception)
+          exception.original_exception
+        else
+          exception
+        end
+
+        if actual_exception.is_a?(WillPaginate::InvalidPage)
           Rack::Utils.status_code(:not_found)
         else
           original_method = method(:status_code_without_paginate)
@@ -69,3 +69,7 @@ module WillPaginate
     end
   end
 end
+
+ActiveSupport.on_load :i18n do
+  I18n.load_path.concat(WillPaginate::I18n.load_path)
+end
diff --git a/lib/will_paginate/version.rb b/lib/will_paginate/version.rb
index 4149c6b..2f6b03b 100644
--- a/lib/will_paginate/version.rb
+++ b/lib/will_paginate/version.rb
@@ -2,7 +2,7 @@ module WillPaginate #:nodoc:
   module VERSION #:nodoc:
     MAJOR = 3
     MINOR = 1
-    TINY  = 0
+    TINY  = 5
 
     STRING = [MAJOR, MINOR, TINY].join('.')
   end
diff --git a/lib/will_paginate/view_helpers/action_view.rb b/lib/will_paginate/view_helpers/action_view.rb
index 0fba71e..6e27892 100644
--- a/lib/will_paginate/view_helpers/action_view.rb
+++ b/lib/will_paginate/view_helpers/action_view.rb
@@ -99,6 +99,8 @@ module WillPaginate
     class LinkRenderer < ViewHelpers::LinkRenderer
       protected
 
+      GET_PARAMS_BLACKLIST = [:script_name, :original_script_name]
+
       def default_url_params
         {}
       end
@@ -118,7 +120,7 @@ module WillPaginate
 
       def merge_get_params(url_params)
         if @template.respond_to? :request and @template.request and @template.request.get?
-          symbolized_update(url_params, @template.params)
+          symbolized_update(url_params, @template.params, GET_PARAMS_BLACKLIST)
         end
         url_params
       end
diff --git a/lib/will_paginate/view_helpers/link_renderer.rb b/lib/will_paginate/view_helpers/link_renderer.rb
index d1745f8..e08168c 100644
--- a/lib/will_paginate/view_helpers/link_renderer.rb
+++ b/lib/will_paginate/view_helpers/link_renderer.rb
@@ -41,10 +41,10 @@ module WillPaginate
     protected
     
       def page_number(page)
-        unless page == current_page
-          link(page, page, :rel => rel_value(page))
-        else
+        if page == current_page
           tag(:em, page, :class => 'current')
+        else
+          link(page, page, :rel => rel_value(page))
         end
       end
       
@@ -108,18 +108,18 @@ module WillPaginate
 
       def rel_value(page)
         case page
-        when @collection.current_page - 1; 'prev' + (page == 1 ? ' start' : '')
+        when @collection.current_page - 1; 'prev'
         when @collection.current_page + 1; 'next'
-        when 1; 'start'
         end
       end
 
-      def symbolized_update(target, other)
-        other.each do |key, value|
+      def symbolized_update(target, other, blacklist = nil)
+        other.each_pair do |key, value|
           key = key.to_sym
           existing = target[key]
-          
-          if value.is_a?(Hash) and (existing.is_a?(Hash) or existing.nil?)
+          next if blacklist && blacklist.include?(key)
+
+          if value.respond_to?(:each_pair) and (existing.is_a?(Hash) or existing.nil?)
             symbolized_update(existing || (target[key] = {}), value)
           else
             target[key] = value
diff --git a/lib/will_paginate/view_helpers/link_renderer_base.rb b/lib/will_paginate/view_helpers/link_renderer_base.rb
index 385b1b2..0ef3137 100644
--- a/lib/will_paginate/view_helpers/link_renderer_base.rb
+++ b/lib/will_paginate/view_helpers/link_renderer_base.rb
@@ -30,7 +30,7 @@ module WillPaginate
         window_from = current_page - inner_window
         window_to = current_page + inner_window
         
-        # adjust lower or upper limit if other is out of bounds
+        # adjust lower or upper limit if either is out of bounds
         if window_to > total_pages
           window_from -= window_to - total_pages
           window_to = total_pages
diff --git a/metadata.yml b/metadata.yml
index 4aa4923..c4c3df1 100644
--- a/metadata.yml
+++ b/metadata.yml
@@ -1,14 +1,14 @@
 --- !ruby/object:Gem::Specification
 name: will_paginate
 version: !ruby/object:Gem::Version
-  version: 3.1.0
+  version: 3.1.5
 platform: ruby
 authors:
 - Mislav Marohnić
 autorequire: 
 bindir: bin
 cert_chain: []
-date: 2016-01-03 00:00:00.000000000 Z
+date: 2016-10-15 00:00:00.000000000 Z
 dependencies: []
 description: will_paginate provides a simple API for performing paginated queries
   with Active Record, DataMapper and Sequel, and includes helpers for rendering pagination
diff --git a/spec/database.yml b/spec/database.yml
index 7930ee8..28a7e54 100644
--- a/spec/database.yml
+++ b/spec/database.yml
@@ -3,23 +3,27 @@ sqlite3:
   adapter: sqlite3
   timeout: 500
 
-mysql:
+mysql: &mysql
   adapter: mysql
   database: will_paginate
   username: 
   encoding: utf8
-  socket: <%= ENV["BOXEN_MYSQL_SOCKET"] %>
+<% if File.exist?("/var/run/mysql5/mysqld.sock") %>
+  host: localhost
+  socket: /var/run/mysql5/mysqld.sock
+<% elsif File.exist? "/tmp/mysql.sock" %>
+  host: localhost
+  socket: /tmp/mysql.sock
+<% else %>
+  host: 127.0.0.1
+<% end %>
 
 mysql2:
+  <<: *mysql
   adapter: mysql2
-  database: will_paginate
-  username: 
-  encoding: utf8
-  socket: <%= ENV["BOXEN_MYSQL_SOCKET"] %>
 
 postgres:
   adapter: postgresql
   database: will_paginate
   username: <%= "postgres" if ENV["TRAVIS"] %>
   min_messages: warning
-  port: <%= ENV["BOXEN_POSTGRESQL_PORT"] %>
diff --git a/spec/view_helpers/action_view_spec.rb b/spec/view_helpers/action_view_spec.rb
index a22e131..4bf341d 100644
--- a/spec/view_helpers/action_view_spec.rb
+++ b/spec/view_helpers/action_view_spec.rb
@@ -80,9 +80,9 @@ describe WillPaginate::ActionView do
         validate_page_numbers [1,1,3,3], elements
         # test rel attribute values:
         text(elements[0]).should == 'Prev'
-        elements[0]['rel'].should == 'prev start'
+        elements[0]['rel'].should == 'prev'
         text(elements[1]).should == '1'
-        elements[1]['rel'].should == 'prev start'
+        elements[1]['rel'].should == 'prev'
         text(elements[3]).should == 'Next'
         elements[3]['rel'].should == 'next'
       end
@@ -201,6 +201,13 @@ describe WillPaginate::ActionView do
     assert_no_links_match /99/
     assert_no_links_match /ftp/
   end
+
+  it "doesn't allow tampering with script_name" do
+    request.params :script_name => 'p0wned', :original_script_name => 'p0wned'
+    paginate
+    assert_links_match %r{^/foo/bar}
+    assert_no_links_match /p0wned/
+  end
   
   it "should not preserve parameters on POST" do
     request.post
@@ -250,7 +257,7 @@ describe WillPaginate::ActionView do
   end
 
   it "should paginate with custom route page parameter" do
-    request.symbolized_path_parameters.update :controller => 'dummy', :action => nil
+    request.symbolized_path_parameters.update :controller => 'dummy', :action => 'index'
     paginate :per_page => 2 do
       assert_select 'a[href]', 6 do |links|
         assert_links_match %r{/page/(\d+)$}, links, [2, 3, 4, 5, 6, 2]
@@ -268,7 +275,7 @@ describe WillPaginate::ActionView do
   end
 
   it "should paginate with custom route and first page number implicit" do
-    request.symbolized_path_parameters.update :controller => 'ibocorp', :action => nil
+    request.symbolized_path_parameters.update :controller => 'ibocorp', :action => 'index'
     paginate :page => 2, :per_page => 2 do
       assert_select 'a[href]', 7 do |links|
         assert_links_match %r{/ibocorp(?:/(\d+))?$}, links, [nil, nil, 3, 4, 5, 6, 3]
@@ -409,7 +416,7 @@ class DummyRequest
   def initialize(controller)
     @controller = controller
     @get = true
-    @params = {}
+    @params = {}.with_indifferent_access
     @symbolized_path_parameters = { :controller => 'foo', :action => 'bar' }
   end
 
@@ -435,7 +442,11 @@ class DummyRequest
 
   def params(more = nil)
     @params.update(more) if more
-    @params
+    if defined?(ActionController::Parameters)
+      ActionController::Parameters.new(@params)
+    else
+      @params
+    end
   end
   
   def host_with_port
@@ -451,3 +462,7 @@ class DummyRequest
     'http:'
   end
 end
+
+if defined?(ActionController::Parameters)
+  ActionController::Parameters.permit_all_parameters = false
+end
diff --git a/spec/view_helpers/view_example_group.rb b/spec/view_helpers/view_example_group.rb
index b482266..815c20d 100644
--- a/spec/view_helpers/view_example_group.rb
+++ b/spec/view_helpers/view_example_group.rb
@@ -143,4 +143,4 @@ module HTML
       childless?? '' : super
     end
   end
-end
+end if defined?(HTML)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-will-paginate.git



More information about the Pkg-ruby-extras-commits mailing list