Skip to content

Commit

Permalink
implicitly rendering a js response should not use the default layout [r…
Browse files Browse the repository at this point in the history
…ails#1844 state:resolved]

Signed-off-by: Joshua Peek <josh@joshpeek.com>
  • Loading branch information
adamlogic authored and josh committed Feb 5, 2009
1 parent b6e7a76 commit 06182ea
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/layout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion actionpack/test/controller/render_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alert('hello');

0 comments on commit 06182ea

Please sign in to comment.