mirror of https://github.com/rails/rails
Merge pull request #50699 from jonathanhefner/follow-up-50665
Do not mask `NoMethodError` from within `render_in`
This commit is contained in:
commit
c66b655bf8
|
@ -14,8 +14,12 @@ module ActionView
|
|||
|
||||
def render(context, *args)
|
||||
@renderable.render_in(context)
|
||||
rescue NoMethodError
|
||||
rescue NoMethodError => error
|
||||
if error.name == :render_in
|
||||
raise ArgumentError, "'#{@renderable.inspect}' is not a renderable object. It must implement #render_in."
|
||||
else
|
||||
raise
|
||||
end
|
||||
end
|
||||
|
||||
def format
|
||||
|
|
|
@ -312,6 +312,15 @@ module RenderTestCases
|
|||
end
|
||||
end
|
||||
|
||||
def test_render_renderable_does_not_mask_nomethoderror_from_within_render_in
|
||||
renderable = Object.new
|
||||
renderable.define_singleton_method(:render_in) { |*| nil.foo }
|
||||
|
||||
assert_raises NoMethodError, match: "undefined method `foo' for nil" do
|
||||
@view.render renderable: renderable
|
||||
end
|
||||
end
|
||||
|
||||
def test_render_partial_starting_with_a_capital
|
||||
assert_nothing_raised { @view.render(partial: "test/FooBar") }
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue