From dcc11b22828ac2a52f136d00a732a38bd9371a16 Mon Sep 17 00:00:00 2001 From: Tieg Zaharia Date: Mon, 16 Apr 2012 13:53:51 -0400 Subject: catch nil.to_sym errors in partial_renderer, and raise ArgumentError instead --- actionpack/lib/action_view/renderer/partial_renderer.rb | 2 +- actionpack/test/template/render_test.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_view/renderer/partial_renderer.rb b/actionpack/lib/action_view/renderer/partial_renderer.rb index 25c41f042b..f96b1c6ef3 100644 --- a/actionpack/lib/action_view/renderer/partial_renderer.rb +++ b/actionpack/lib/action_view/renderer/partial_renderer.rb @@ -407,7 +407,7 @@ module ActionView end def retrieve_variable(path) - variable = @options[:as].try(:to_sym) || path[%r'_?(\w+)(\.\w+)*$', 1].to_sym + variable = @options[:as].try(:to_sym) || path[%r'_?(\w+)(\.\w+)*$', 1].try(:to_sym) variable_counter = :"#{variable}_counter" if @collection [variable, variable_counter] end diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index 503bbb207e..2be91b8b45 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -161,6 +161,15 @@ module RenderTestCases "and is followed by any combinations of letters, numbers, or underscores.", e.message end + def test_render_partial_with_missing_filename + @view.render(:partial => "test/") + flunk "Render did not raise ArgumentError" + rescue ArgumentError => e + assert_equal "The partial name (test/) is not a valid Ruby identifier; " + + "make sure your partial name starts with a letter or underscore, " + + "and is followed by any combinations of letters, numbers, or underscores.", e.message + end + def test_render_partial_with_incompatible_object @view.render(:partial => nil) flunk "Render did not raise ArgumentError" -- cgit v1.2.3