Permalink
Browse files

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

…instead
  • Loading branch information...
1 parent 773aad8 commit e25e87a5433637e23b40af07ababb2dcc093a9a9 @tiegz tiegz committed with Apr 16, 2012
@@ -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
@@ -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 e25e87a

Please sign in to comment.