Skip to content

Commit

Permalink
hwia the given params per each tag only once
Browse files Browse the repository at this point in the history
  • Loading branch information
amatsuda committed Jul 24, 2015
1 parent 56ab061 commit c4125e7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/kaminari/helpers/tags.rb
Expand Up @@ -21,6 +21,7 @@ def initialize(template, options = {}) #:nodoc:
@theme = @options.delete(:theme)
@views_prefix = @options.delete(:views_prefix)
@params = template.params.except(*PARAM_KEY_BLACKLIST).merge(@options.delete(:params) || {})
@params = @params.with_indifferent_access
end

def to_s(locals = {}) #:nodoc:
Expand All @@ -35,7 +36,7 @@ def page_url_for(page)

def params_for(page)
page_params = Rack::Utils.parse_nested_query("#{@param_name}=#{page}")
page_params = @params.with_indifferent_access.deep_merge(page_params)
page_params = @params.deep_merge(page_params)

if !Kaminari.config.params_on_first_page && (page <= 1)
# This converts a hash:
Expand Down
4 changes: 2 additions & 2 deletions spec/helpers/helpers_spec.rb
Expand Up @@ -26,7 +26,7 @@
@paginator = Paginator.new(template, :params => {:controller => 'foo', :action => 'bar'})
end
subject { @paginator.page_tag(template).instance_variable_get('@params') }
it { should == {:controller => 'foo', :action => 'bar'} }
it { should == {'controller' => 'foo', 'action' => 'bar'} }

context "when params has form params" do
before do
Expand All @@ -40,7 +40,7 @@
end
end

it { should == {:controller => 'foo', :action => 'bar'} }
it { should == {'controller' => 'foo', 'action' => 'bar'} }
end
end

Expand Down

0 comments on commit c4125e7

Please sign in to comment.