Ticket #6808: json_layout_patch.diff
| File json_layout_patch.diff, 1.7 kB (added by josh, 2 years ago) |
|---|
-
test/controller/render_test.rb
old new 47 47 render_json({:hello => 'world'}.to_json, 'alert') 48 48 end 49 49 50 def render_symbol_json 51 render :json => {:hello => 'world'}.to_json 52 end 53 50 54 def render_custom_code 51 55 render_text "hello world", "404 Moved" 52 56 end … … 125 129 case action_name 126 130 when "layout_test": "layouts/standard" 127 131 when "builder_layout_test": "layouts/builder" 132 when "render_symbol_json": "layouts/standard" # to make sure layouts don't interfere 128 133 end 129 134 end 130 135 end … … 184 189 assert_equal 'application/json', @response.content_type 185 190 end 186 191 192 def test_do_with_render_symbol_json 193 get :render_symbol_json 194 assert_equal '{hello: "world"}', @response.body 195 assert_equal 'application/json', @response.content_type 196 end 197 187 198 def test_do_with_render_custom_code 188 199 get :render_custom_code 189 200 assert_response 404 -
lib/action_controller/layout.rb
old new 266 266 267 267 def candidate_for_layout?(options) 268 268 (options.has_key?(:layout) && options[:layout] != false) || 269 options.values_at(:text, :xml, : file, :inline, :partial, :nothing).compact.empty? &&269 options.values_at(:text, :xml, :json, :file, :inline, :partial, :nothing).compact.empty? && 270 270 !template_exempt_from_layout?(default_template_name(options[:action] || options[:template])) 271 271 end 272 272