Skip to content
Browse files

catch nil.to_sym errors in partial_renderer, and raise ArgumentError …

…instead
  • Loading branch information...
1 parent a0c2cfd commit dfab28b2ca28b477f83befbba639adb6d15c8ce0 @tiegz tiegz committed Apr 16, 2012
View
2 actionpack/lib/action_view/renderer/partial_renderer.rb
@@ -451,7 +451,7 @@ def merge_prefix_into_object_path(prefix, object_path)
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
View
9 actionpack/test/template/render_test.rb
@@ -161,6 +161,15 @@ def test_render_partial_with_invalid_name
"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"

0 comments on commit dfab28b

Please sign in to comment.
Something went wrong with that request. Please try again.