Do not mask NoMethodError for render_in in render_in

Follow-up to #50699.

This prevents a `NoMethodError` from being masked when the missing
method is itself named `render_in`.

Co-authored-by: Hartley McGuire <skipkayhil@gmail.com>
This commit is contained in:
Jonathan Hefner 2024-01-10 17:26:27 -06:00
parent c66b655bf8
commit 91968e5a18
2 changed files with 4 additions and 4 deletions

View File

@ -14,8 +14,8 @@ module ActionView
def render(context, *args)
@renderable.render_in(context)
rescue NoMethodError => error
if error.name == :render_in
rescue NoMethodError
if !@renderable.respond_to?(:render_in)
raise ArgumentError, "'#{@renderable.inspect}' is not a renderable object. It must implement #render_in."
else
raise

View File

@ -314,9 +314,9 @@ module RenderTestCases
def test_render_renderable_does_not_mask_nomethoderror_from_within_render_in
renderable = Object.new
renderable.define_singleton_method(:render_in) { |*| nil.foo }
renderable.define_singleton_method(:render_in) { |*| nil.render_in }
assert_raises NoMethodError, match: "undefined method `foo' for nil" do
assert_raises NoMethodError, match: "undefined method `render_in' for nil" do
@view.render renderable: renderable
end
end