diff --git a/kaminari-core/lib/kaminari/helpers/tags.rb b/kaminari-core/lib/kaminari/helpers/tags.rb index 73b8ec99c..3b5e22c8c 100644 --- a/kaminari-core/lib/kaminari/helpers/tags.rb +++ b/kaminari-core/lib/kaminari/helpers/tags.rb @@ -24,7 +24,14 @@ def initialize(template, params: {}, param_name: nil, theme: nil, views_prefix: @params = @params.to_unsafe_h if @params.respond_to?(:to_unsafe_h) @params = @params.with_indifferent_access @params.except!(*PARAM_KEY_BLACKLIST) - @params.merge! params + # params in Rails 5 may not be a Hash either, + # so it must be converted to a Hash to be merged into @params + unless params.empty? + ActiveSupport::Deprecation.warn 'Explicitly passing params to helpers could be removed in the future.' + params = params.to_unsafe_h if params.respond_to?(:to_unsafe_h) + params = params.with_indifferent_access + @params.merge! params + end end def to_s(locals = {}) #:nodoc: diff --git a/kaminari-core/test/helpers/tags_test.rb b/kaminari-core/test/helpers/tags_test.rb index feb8bd961..c6cca130f 100644 --- a/kaminari-core/test/helpers/tags_test.rb +++ b/kaminari-core/test/helpers/tags_test.rb @@ -67,6 +67,20 @@ class TagTest < ActionView::TestCase end end + sub_test_case "when passing nested params" do + setup do + self.params[:filter] = ActionController::Parameters.new({status: 'active'}) + end + + test 'for first page' do + assert_match(/users\?filter%5Bstatus%5D=active/, Kaminari::Helpers::Tag.new(self, params: self.params).page_url_for(1)) + end + + test 'for other page' do + assert_match(/users\?filter%5Bstatus%5D=active&page=2/, Kaminari::Helpers::Tag.new(self, params: self.params).page_url_for(2)) + end + end + sub_test_case "with param_name = 'foo.page' option" do setup do self.params['foo.page'] = 2