diff options
author | Tieg Zaharia <tieg@kickstarter.com> | 2012-04-16 13:53:51 -0400 |
---|---|---|
committer | Tieg Zaharia <tieg@kickstarter.com> | 2012-04-16 13:53:51 -0400 |
commit | dcc11b22828ac2a52f136d00a732a38bd9371a16 (patch) | |
tree | 75d782c9e44142d9c86645ccaaa8e09d0fbbd692 | |
parent | 9a97699460e9b35a4c9e7a9694cf444fa75c7861 (diff) | |
download | rails-dcc11b22828ac2a52f136d00a732a38bd9371a16.tar.gz rails-dcc11b22828ac2a52f136d00a732a38bd9371a16.tar.bz2 rails-dcc11b22828ac2a52f136d00a732a38bd9371a16.zip |
catch nil.to_sym errors in partial_renderer, and raise ArgumentError instead
-rw-r--r-- | actionpack/lib/action_view/renderer/partial_renderer.rb | 2 | ||||
-rw-r--r-- | actionpack/test/template/render_test.rb | 9 |
2 files changed, 10 insertions, 1 deletions
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" |