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

This commit is contained in:
Tieg Zaharia
2012-04-16 13:53:51 -04:00
parent 9a97699460
commit dcc11b2282
2 changed files with 10 additions and 1 deletions

View File

@@ -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

View File

@@ -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"