From 23315ee3f51504b3d6c9d05bf3c7c7d04d965793 Mon Sep 17 00:00:00 2001 From: Adam McCrea Date: Wed, 4 Feb 2009 10:43:07 -0500 Subject: [PATCH] implicitly rendering a js response should not use the default layout --- actionpack/lib/action_controller/layout.rb | 2 +- actionpack/test/controller/render_test.rb | 11 ++++++++++- ...nder_implicit_js_template_without_layout.js.erb | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 actionpack/test/fixtures/test/render_implicit_js_template_without_layout.js.erb diff --git a/actionpack/lib/action_controller/layout.rb b/actionpack/lib/action_controller/layout.rb index 183d56c..d6bcf7a 100644 --- a/actionpack/lib/action_controller/layout.rb +++ b/actionpack/lib/action_controller/layout.rb @@ -173,7 +173,7 @@ module ActionController #:nodoc: end def default_layout(format) #:nodoc: - layout = read_inheritable_attribute(:layout) + layout = read_inheritable_attribute(:layout) unless format == :js return layout unless read_inheritable_attribute(:auto_layout) find_layout(layout, format) end diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index 584b927..e131a73 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -277,6 +277,9 @@ class TestController < ActionController::Base def render_implicit_html_template_from_xhr_request end + def render_implicit_js_template_without_layout + end + def formatted_html_erb end @@ -681,7 +684,8 @@ class TestController < ActionController::Base "render_with_explicit_string_template", "render_js_with_explicit_template", "render_js_with_explicit_action_template", - "delete_with_js", "update_page", "update_page_with_instance_variables" + "delete_with_js", "update_page", "update_page_with_instance_variables", + "render_implicit_js_template_without_layout" "layouts/standard" when "action_talk_to_layout", "layout_overriding_layout" @@ -1018,6 +1022,11 @@ class RenderTest < ActionController::TestCase assert_equal "Hello HTML!", @response.body end + def test_should_implicitly_render_js_template_without_layout + get :render_implicit_js_template_without_layout, :format => :js + assert_no_match //, @response.body + end + def test_should_render_formatted_template get :formatted_html_erb assert_equal 'formatted html erb', @response.body diff --git a/actionpack/test/fixtures/test/render_implicit_js_template_without_layout.js.erb b/actionpack/test/fixtures/test/render_implicit_js_template_without_layout.js.erb new file mode 100644 index 0000000..d5b94af --- /dev/null +++ b/actionpack/test/fixtures/test/render_implicit_js_template_without_layout.js.erb @@ -0,0 +1 @@ +alert('hello'); -- 1.6.0.4