Permalink
Browse files

catch possible WSOD when trying to render a missing partial. Closes #…

…8454 [Catfish]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6826 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent da7f9f5 commit 4b9e67c5b9d9f751d633c787d24a1491f3ef498e @technoweenie technoweenie committed May 24, 2007
Showing with 16 additions and 0 deletions.
  1. +2 −0 actionpack/CHANGELOG
  2. +4 −0 actionpack/lib/action_view/base.rb
  3. +10 −0 actionpack/test/controller/new_render_test.rb
@@ -1,5 +1,7 @@
*SVN*
+* catch possible WSOD when trying to render a missing partial. Closes #8454 [Catfish]
+
* Rewind request body after reading it, if possible. #8438 [s450r1]
* Resource namespaces are inherited by their has_many subresources. #8280 [marclove, ggarside]
@@ -278,6 +278,10 @@ def render_file(template_path, use_full_path = true, local_assigns = {}) #:nodoc
template_source = nil # Don't read the source until we know that it is required
+ if template_file_name.blank?
+ raise ActionViewError, "Couldn't find template file for #{template_path} in #{@view_paths.inspect}"
+ end
+
begin
render_template(template_extension, template_source, template_file_name, local_assigns)
rescue Exception => e
@@ -163,6 +163,10 @@ def partial_with_implicit_local_assignment
render :partial => "customer"
end
+ def missing_partial
+ render :partial => 'thisFileIsntHere'
+ end
+
def hello_in_a_string
@customers = [ Customer.new("david"), Customer.new("mary") ]
render :text => "How's there? #{render_to_string("test/list")}"
@@ -682,6 +686,12 @@ def test_partial_with_implicit_local_assignment
assert_equal "Hello: Marcel", @response.body
end
+ def test_render_missing_partial_template
+ assert_raises(ActionView::ActionViewError) do
+ get :missing_partial
+ end
+ end
+
def test_render_text_with_assigns
get :render_text_with_assigns
assert_equal "world", assigns["hello"]

0 comments on commit 4b9e67c

Please sign in to comment.