diff options
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_controller/layout.rb | 2 | ||||
-rw-r--r-- | actionpack/test/controller/layout_test.rb | 21 |
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 |