diff options
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_controller/layout.rb | 2 | ||||
-rw-r--r-- | actionpack/test/controller/render_test.rb | 11 |
3 files changed, 14 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index c7cd0efd4b..d7dc6153b7 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Ensure render :json => ... skips the layout. Closes #6808 [Josh Peek] + * Fix HTML::Node to output double quotes instead of single quotes. Closes #6845 [mitreandy] * Correctly report which filter halted the chain. #6699 [Martin Emde] diff --git a/actionpack/lib/action_controller/layout.rb b/actionpack/lib/action_controller/layout.rb index f6d687bd10..0d0a843e33 100644 --- a/actionpack/lib/action_controller/layout.rb +++ b/actionpack/lib/action_controller/layout.rb @@ -266,7 +266,7 @@ module ActionController #:nodoc: 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 diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index b223862c9e..d364dd6c93 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -47,6 +47,10 @@ class TestController < ActionController::Base 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 @@ -125,6 +129,7 @@ class TestController < ActionController::Base 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 @@ -184,6 +189,12 @@ class RenderTest < Test::Unit::TestCase 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 |