Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge [5746] from trunk.
git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-pre-release@5765 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
jeremy committed Dec 21, 2006
1 parent 8ec9f4d commit debd9ea
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*1.13.0 RC2*

* Ensure render :json => ... skips the layout. #6808 [Josh Peek]

* Silence log_error deprecation warnings from inspecting deprecated instance variables. [Nate Wiger]

* Only cache GET requests with a 200 OK response. #6514, #6743 [RSL, anamba]
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/layout.rb
Expand Up @@ -266,7 +266,7 @@ def apply_layout?(template_with_options, options)

def candidate_for_layout?(options)
(options.has_key?(:layout) && options[:layout] != false) ||
options.values_at(:text, :xml, :file, :inline, :partial, :nothing).compact.empty? &&
options.values_at(:text, :xml, :json, :file, :inline, :partial, :nothing).compact.empty? &&
!template_exempt_from_layout?(default_template_name(options[:action] || options[:template]))
end

Expand Down
11 changes: 11 additions & 0 deletions actionpack/test/controller/render_test.rb
Expand Up @@ -47,6 +47,10 @@ def render_json_hello_world_with_callback
render_json({:hello => 'world'}.to_json, 'alert')
end

def render_symbol_json
render :json => {:hello => 'world'}.to_json
end

def render_custom_code
render_text "hello world", "404 Moved"
end
Expand Down Expand Up @@ -125,6 +129,7 @@ def determine_layout
case action_name
when "layout_test": "layouts/standard"
when "builder_layout_test": "layouts/builder"
when "render_symbol_json": "layouts/standard" # to make sure layouts don't interfere
end
end
end
Expand Down Expand Up @@ -184,6 +189,12 @@ def test_do_with_render_json_with_callback
assert_equal 'application/json', @response.content_type
end

def test_do_with_render_symbol_json
get :render_symbol_json
assert_equal '{hello: "world"}', @response.body
assert_equal 'application/json', @response.content_type
end

def test_do_with_render_custom_code
get :render_custom_code
assert_response 404
Expand Down

0 comments on commit debd9ea

Please sign in to comment.