Skip to content

Commit

Permalink
Fix URL generation when explicitly passing params to link helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
5t111111 committed Mar 9, 2017
1 parent 1c9ec36 commit 1bb3dbd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion kaminari-core/lib/kaminari/helpers/tags.rb
Expand Up @@ -24,7 +24,7 @@ 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.reverse_merge! params
end

def to_s(locals = {}) #:nodoc:
Expand Down
14 changes: 14 additions & 0 deletions kaminari-core/test/helpers/tags_test.rb
Expand Up @@ -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
Expand Down

0 comments on commit 1bb3dbd

Please sign in to comment.