Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
@adamlogic adamlogic authored josh committed
View
2  actionpack/lib/action_controller/layout.rb
@@ -173,7 +173,7 @@ def layout_conditions #: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
View
11 actionpack/test/controller/render_test.rb
@@ -277,6 +277,9 @@ def render_explicit_html_template
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 @@ def determine_layout
"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 @@ def test_should_implicitly_render_html_template_from_xhr_request
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 /<html>/, @response.body
+ end
+
def test_should_render_formatted_template
get :formatted_html_erb
assert_equal 'formatted html erb', @response.body
View
1  actionpack/test/fixtures/test/render_implicit_js_template_without_layout.js.erb
@@ -0,0 +1 @@
+alert('hello');
Please sign in to comment.
Something went wrong with that request. Please try again.