aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-07-05 02:38:55 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-07-05 02:38:55 +0000
commit11c715a53fd6309c37883b7d44462cc0a66f3bba (patch)
treee806db190d63f9628a8c0fc91da5f6da61e7329f
parent73c80169c85d6405940dc6c45dcc0ccff9d689df (diff)
downloadrails-11c715a53fd6309c37883b7d44462cc0a66f3bba.tar.gz
rails-11c715a53fd6309c37883b7d44462cc0a66f3bba.tar.bz2
rails-11c715a53fd6309c37883b7d44462cc0a66f3bba.zip
Added exception handling of missing layouts (closes #5373) [chris@ozmm.org]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4550 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_controller/layout.rb2
-rw-r--r--actionpack/test/controller/layout_test.rb21
3 files changed, 24 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index c85acf800b..2cf28dd283 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Added exception handling of missing layouts #5373 [chris@ozmm.org]
+
* Fixed that real files and symlinks should be treated the same when compiling templates #5438 [zachary@panandscan.com]
* Fixed that the flash should be reset when reset_session is called #5584 [shugo@ruby-lang.org]
diff --git a/actionpack/lib/action_controller/layout.rb b/actionpack/lib/action_controller/layout.rb
index e421f8ed9e..91ca16913e 100644
--- a/actionpack/lib/action_controller/layout.rb
+++ b/actionpack/lib/action_controller/layout.rb
@@ -236,6 +236,8 @@ module ActionController #:nodoc:
template_with_options = options.is_a?(Hash)
if apply_layout?(template_with_options, options) && (layout = pick_layout(template_with_options, options, deprecated_layout))
+ assert_existence_of_template_file(layout)
+
options = options.merge :layout => false if template_with_options
logger.info("Rendering #{options} within #{layout}") if logger
diff --git a/actionpack/test/controller/layout_test.rb b/actionpack/test/controller/layout_test.rb
index 9dc0cdcfe9..bbb13d0320 100644
--- a/actionpack/test/controller/layout_test.rb
+++ b/actionpack/test/controller/layout_test.rb
@@ -121,4 +121,23 @@ class LayoutSetInResponseTest < Test::Unit::TestCase
get :hello
assert_nil @response.layout
end
-end \ No newline at end of file
+end
+
+
+class SetsNonExistentLayoutFile < LayoutTest
+ layout "nofile.rhtml"
+end
+
+class LayoutExceptionRaised < Test::Unit::TestCase
+ def setup
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ end
+
+ def test_exception_raised_when_layout_file_not_found
+ @controller = SetsNonExistentLayoutFile.new
+ get :hello
+ @response.template.class.module_eval { attr_accessor :exception }
+ assert_equal ActionController::MissingTemplate, @response.template.exception.class
+ end
+end