Permalink
Browse files

Added exception handling of missing layouts (closes #5373) [chris@ozm…

…m.org]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4550 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 73c8016 commit 11c715a53fd6309c37883b7d44462cc0a66f3bba @dhh dhh committed Jul 5, 2006
Showing with 24 additions and 1 deletion.
  1. +2 −0 actionpack/CHANGELOG
  2. +2 −0 actionpack/lib/action_controller/layout.rb
  3. +20 −1 actionpack/test/controller/layout_test.rb
View
@@ -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]
@@ -236,6 +236,8 @@ def render_with_a_layout(options = nil, deprecated_status = nil, deprecated_layo
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
@@ -121,4 +121,23 @@ def test_layout_is_not_set_when_none_rendered
get :hello
assert_nil @response.layout
end
-end
+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

0 comments on commit 11c715a

Please sign in to comment.