Skip to content

Commit

Permalink
Merge pull request #1114 from intellum/fix-helpers-kwargs-ruby-3
Browse files Browse the repository at this point in the history
Fixes helpers with keyword arguments #1082

fixes #1082
  • Loading branch information
amatsuda committed Apr 4, 2024
2 parents e1789de + 9c07f28 commit 9182d06
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kaminari-core/lib/kaminari/helpers/paginator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ def to_s #:nodoc:
end

# delegates view helper methods to @template
def method_missing(name, *args, &block)
@template.respond_to?(name) ? @template.send(name, *args, &block) : super
def method_missing(name, *args, **kwargs, &block)
@template.respond_to?(name) ? @template.send(name, *args, **kwargs, &block) : super
end
private :method_missing

Expand Down
6 changes: 6 additions & 0 deletions kaminari-core/test/helpers/helpers_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def template
url_for {|h| "/foo?page=#{h[:page]}"}
link_to { "<a href='#'>link</a>" }
output_buffer { defined?(ActionView) ? ::ActionView::OutputBuffer.new : ::ActiveSupport::SafeBuffer.new }
t { |*args, **kwargs| [args, kwargs] }
end
r
end
Expand All @@ -22,6 +23,11 @@ def template
assert_equal "<a href='#'>link</a>", paginator.link_to('link', '#')
end

test 'view helper methods delegated to template with kwargs work correctly' do
paginator = Paginator.new(template, params: {})
assert_equal [['positional'], {keyword: :value}], paginator.t('positional', keyword: :value)
end

sub_test_case '#params' do
setup do
@paginator = Paginator.new(template, params: {controller: 'foo', action: 'bar'})
Expand Down

0 comments on commit 9182d06

Please sign in to comment.