Paginator should delegate view helper methods to template

fixes #239
This commit is contained in:
Yuki Nishijima 2014-03-15 15:18:54 -07:00
parent f63112eb40
commit defc7ba92e
2 changed files with 15 additions and 0 deletions

View File

@ -106,6 +106,12 @@ module Kaminari
end
end
# delegates view helper methods to @template
def method_missing(name, *args, &block)
@template.respond_to?(name) ? @template.send(name, *args, &block) : super
end
private :method_missing
# Wraps a "page number" and provides some utility methods
class PageProxy
include Comparable

View File

@ -8,10 +8,19 @@ describe 'Kaminari::Helpers::Paginator' do
params { {} }
options { {} }
url_for {|h| "/foo?page=#{h[:page]}"}
link_to { "<a href='#'>link</a>" }
end
r
end
describe "view helper methods delegated to template" do
before do
@paginator = Paginator.new(template, :params => {})
end
subject { @paginator.link_to("link", "#") }
it { should == "<a href='#'>link</a>" }
end
describe '#params' do
before do
@paginator = Paginator.new(template, :params => {:controller => 'foo', :action => 'bar'})