From f1b12b62f48257054a416269f3bf465fb4a8d6e7 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 8 Sep 2007 03:12:03 +0000 Subject: Fix layout overriding response status. Closes #9476. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7418 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/CHANGELOG | 2 ++ actionpack/lib/action_controller/layout.rb | 3 ++- actionpack/test/controller/layout_test.rb | 19 +++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) (limited to 'actionpack') diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 50af35eb14..ac1c568a94 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fix layout overriding response status. #9476 [lotswholetime] + * Add fieldset_tag for generating fieldsets, closes #9477. [djanowski] * Allow additional parameters to be passed to named route helpers when using positional arguments. Closes #8930 [ian.w.white@gmail.com] diff --git a/actionpack/lib/action_controller/layout.rb b/actionpack/lib/action_controller/layout.rb index ff4a4057a2..5655a9bd0b 100644 --- a/actionpack/lib/action_controller/layout.rb +++ b/actionpack/lib/action_controller/layout.rb @@ -247,7 +247,8 @@ module ActionController #:nodoc: add_variables_to_assigns @template.instance_variable_set("@content_for_layout", content_for_layout) response.layout = layout - render_for_text(@template.render_file(layout, true)) + status = template_with_options ? options[:status] : nil + render_for_text(@template.render_file(layout, true), status) else render_with_no_layout(options, &block) end diff --git a/actionpack/test/controller/layout_test.rb b/actionpack/test/controller/layout_test.rb index 1f8baca49a..cad5720742 100644 --- a/actionpack/test/controller/layout_test.rb +++ b/actionpack/test/controller/layout_test.rb @@ -200,3 +200,22 @@ class LayoutExceptionRaised < Test::Unit::TestCase assert_equal ActionController::MissingTemplate, @response.template.exception.class end end + +class LayoutStatusIsRendered < LayoutTest + def hello + render :status => 401 + end +end + +class LayoutStatusIsRenderedTest < Test::Unit::TestCase + def setup + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + end + + def test_layout_status_is_rendered + @controller = LayoutStatusIsRendered.new + get :hello + assert_response 401 + end +end -- cgit v1.2.3