mirror of
https://github.com/github/rails.git
synced 2026-01-10 07:07:54 -05:00
catch nil.to_sym errors in partial_renderer, and raise ArgumentError instead
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user