mirror of https://github.com/rails/rails
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:
parent
c66b655bf8
commit
91968e5a18
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue