Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/kaminari/helpers/sinatra_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ def paginate(scope, options = {})
current_path = env['PATH_INFO'] rescue nil
current_params = Rack::Utils.parse_query(env['QUERY_STRING']).symbolize_keys rescue {}

template = ActionViewTemplateProxy.new current_params: current_params, current_path: current_path, param_name: options[:param_name] || Kaminari.config.param_name
template = ActionViewTemplateProxy.new(
current_params: current_params.merge(options[:params]),
current_path: current_path,
param_name: options[:param_name] || Kaminari.config.param_name
)

super scope, {template: template}.merge(options)
end
Expand Down
18 changes: 18 additions & 0 deletions test/helpers/sinatra_helpers_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,24 @@ def last_document
assert_match(/user_page=\d+/, elm.attribute('href').value)
end
end

test 'should allow extra params' do
mock_app do
register Kaminari::Helpers::SinatraHelpers
get '/users' do
@page = params[:page] || 1
@users = User.page(@page).per(3)
@options = {params: {foo: 'bar'}}
erb ERB_TEMPLATE_FOR_PAGINATE.dup
end
end

get '/users'

last_document.search('.page a').each do |elm|
assert_match(/foo=bar/, elm.attribute('href').value)
end
end
end
end

Expand Down