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
This commit is contained in:
David Heinemeier Hansson 2006-07-05 02:38:55 +00:00
parent 73c80169c8
commit 11c715a53f
3 changed files with 24 additions and 1 deletions

View File

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

View File

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

View File

@ -122,3 +122,22 @@ class LayoutSetInResponseTest < Test::Unit::TestCase
assert_nil @response.layout
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