From 67c96ab024f008ad1aee8345c1ae0fd7aa9bf072 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Sun, 15 Jan 2012 22:07:20 -0200 Subject: [PATCH] Move render_to_body logic to return a spaced string to AC::Rendering This seems to be required only when calling render :partial with an empty collection from a controller. This call happens to return no content, letting the response body empty, which means to Rails that it should go on and try to find a template to render based on the current action name, thus failing hard. Although tests keep all green, we need to check a better way to fix this. --- actionpack/lib/action_controller/metal/compatibility.rb | 4 ---- actionpack/lib/action_controller/metal/rendering.rb | 4 ++++ actionpack/lib/action_controller/metal/streaming.rb | 2 +- actionpack/lib/action_view/test_case.rb | 2 -- actionpack/test/controller/filters_test.rb | 2 -- 5 files changed, 5 insertions(+), 9 deletions(-) diff --git a/actionpack/lib/action_controller/metal/compatibility.rb b/actionpack/lib/action_controller/metal/compatibility.rb index 96707b6587..813b6501d1 100644 --- a/actionpack/lib/action_controller/metal/compatibility.rb +++ b/actionpack/lib/action_controller/metal/compatibility.rb @@ -13,9 +13,5 @@ class << self :@_view_runtime, :@_stream, :@_url_options, :@_action_has_layout ] end - - def render_to_body(options) - super || " " - end end end diff --git a/actionpack/lib/action_controller/metal/rendering.rb b/actionpack/lib/action_controller/metal/rendering.rb index f6e9e4c4ac..a677cdf15d 100644 --- a/actionpack/lib/action_controller/metal/rendering.rb +++ b/actionpack/lib/action_controller/metal/rendering.rb @@ -29,6 +29,10 @@ def render_to_string(*) self.response_body = nil end + def render_to_body(*) + super || " " + end + private # Normalize arguments by catching blocks and setting them on :update. diff --git a/actionpack/lib/action_controller/metal/streaming.rb b/actionpack/lib/action_controller/metal/streaming.rb index 0e46402962..e9783e6919 100644 --- a/actionpack/lib/action_controller/metal/streaming.rb +++ b/actionpack/lib/action_controller/metal/streaming.rb @@ -216,7 +216,7 @@ def _process_options(options) #:nodoc: end end - # Call render_to_body if we are streaming instead of usual +render+. + # Call render_body if we are streaming instead of usual +render+. def _render_template(options) #:nodoc: if options.delete(:stream) Rack::Chunked::Body.new view_renderer.render_body(view_context, options) diff --git a/actionpack/lib/action_view/test_case.rb b/actionpack/lib/action_view/test_case.rb index c734c914db..b00f69e636 100644 --- a/actionpack/lib/action_view/test_case.rb +++ b/actionpack/lib/action_view/test_case.rb @@ -233,10 +233,8 @@ def method_missing(selector, *args) super end end - end include Behavior - end end diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb index c64628890e..046396b37c 100644 --- a/actionpack/test/controller/filters_test.rb +++ b/actionpack/test/controller/filters_test.rb @@ -815,8 +815,6 @@ def test_process(controller, action = "show") end end - - class PostsController < ActionController::Base module AroundExceptions class Error < StandardError ; end -- GitLab