Skip to content
This repository
Browse code

implicitly rendering a js response should not use the default layout [#…

…1844 state:resolved]

Signed-off-by: Joshua Peek <josh@joshpeek.com>
  • Loading branch information...
commit 06182ea02e92afad579998aa80144588e8865ac3 1 parent b6e7a76
Adam McCrea authored February 05, 2009 josh committed February 05, 2009
2  actionpack/lib/action_controller/layout.rb
@@ -173,7 +173,7 @@ def layout_conditions #:nodoc:
173 173
       end
174 174
 
175 175
       def default_layout(format) #:nodoc:
176  
-        layout = read_inheritable_attribute(:layout)
  176
+        layout = read_inheritable_attribute(:layout) unless format == :js
177 177
         return layout unless read_inheritable_attribute(:auto_layout)
178 178
         find_layout(layout, format)
179 179
       end
11  actionpack/test/controller/render_test.rb
@@ -277,6 +277,9 @@ def render_explicit_html_template
277 277
   def render_implicit_html_template_from_xhr_request
278 278
   end
279 279
 
  280
+  def render_implicit_js_template_without_layout
  281
+  end
  282
+
280 283
   def formatted_html_erb
281 284
   end
282 285
 
@@ -681,7 +684,8 @@ def determine_layout
681 684
              "render_with_explicit_string_template",
682 685
              "render_js_with_explicit_template",
683 686
              "render_js_with_explicit_action_template",
684  
-             "delete_with_js", "update_page", "update_page_with_instance_variables"
  687
+             "delete_with_js", "update_page", "update_page_with_instance_variables",
  688
+             "render_implicit_js_template_without_layout"
685 689
 
686 690
           "layouts/standard"
687 691
         when "action_talk_to_layout", "layout_overriding_layout"
@@ -1018,6 +1022,11 @@ def test_should_implicitly_render_html_template_from_xhr_request
1018 1022
     assert_equal "Hello HTML!", @response.body
1019 1023
   end
1020 1024
 
  1025
+  def test_should_implicitly_render_js_template_without_layout
  1026
+    get :render_implicit_js_template_without_layout, :format => :js
  1027
+    assert_no_match /<html>/, @response.body
  1028
+  end
  1029
+
1021 1030
   def test_should_render_formatted_template
1022 1031
     get :formatted_html_erb
1023 1032
     assert_equal 'formatted html erb', @response.body
1  actionpack/test/fixtures/test/render_implicit_js_template_without_layout.js.erb
... ...
@@ -0,0 +1 @@
  1
+alert('hello');

0 notes on commit 06182ea

Please sign in to comment.
Something went wrong with that request. Please try again.