mirror of
https://github.com/kaminari/kaminari.git
synced 2022-11-09 13:44:37 -05:00
:params option for the paginator
this overrides each pagination link's url_for option
This commit is contained in:
parent
66bd7f71b0
commit
6bfab14f10
2 changed files with 11 additions and 3 deletions
|
@ -3,10 +3,11 @@ require File.join(File.dirname(__FILE__), 'tags')
|
|||
module Kaminari
|
||||
module Helpers
|
||||
class PaginationRenderer
|
||||
attr_reader :options
|
||||
attr_reader :options, :params
|
||||
|
||||
def initialize(template, options) #:nodoc:
|
||||
@template, @options = template, options
|
||||
@params = options[:params] ? template.params.merge(options.delete :params) : template.params
|
||||
@left, @window, @right = (options[:left] || options[:outer_window] || 1), (options[:window] || options[:inner_window] || 4), (options[:right] || options[:outer_window] || 1)
|
||||
end
|
||||
|
||||
|
@ -104,6 +105,7 @@ module Kaminari
|
|||
# * <tt>:outer_window</tt> - The "outer window" size (1 by default).
|
||||
# * <tt>:left</tt> - The "left outer window" size (1 by default).
|
||||
# * <tt>:right</tt> - The "right outer window" size (1 by default).
|
||||
# * <tt>:params</tt> - url_for parameters for the links (:controller, :action, etc.)
|
||||
# * <tt>:remote</tt> - Ajax? (false by default)
|
||||
# * <tt>:ANY_OTHER_VALUES</tt> - Any other hash key & values would be directly passed into each tag as :locals value.
|
||||
def paginate(scope, options = {}, &block)
|
||||
|
|
|
@ -2,7 +2,7 @@ require File.expand_path('../spec_helper', File.dirname(__FILE__))
|
|||
include Kaminari::Helpers
|
||||
|
||||
describe 'Kaminari::Helpers::PaginationRenderer' do
|
||||
let :renderer do
|
||||
let :template do
|
||||
stub(r = Object.new) do
|
||||
render.with_any_args
|
||||
params { {} }
|
||||
|
@ -10,9 +10,15 @@ describe 'Kaminari::Helpers::PaginationRenderer' do
|
|||
end
|
||||
r
|
||||
end
|
||||
|
||||
describe '#params' do
|
||||
subject { PaginationRenderer.new(template, :params => {:controller => 'foo', :action => 'bar'}) }
|
||||
its(:params) { should == {:controller => 'foo', :action => 'bar'} }
|
||||
end
|
||||
|
||||
describe '#tagify_links' do
|
||||
def tags_with(options)
|
||||
PaginationRenderer.new(renderer, options).tagify_links
|
||||
PaginationRenderer.new(template, options).tagify_links
|
||||
end
|
||||
|
||||
context '1 page in total' do
|
||||
|
|
Loading…
Add table
Reference in a new issue