From 4c52ba278b8e349bc18cb89086af765d0828f0af Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Thu, 21 May 2009 20:22:18 -0700 Subject: Move Safari response-padding fix to Rails2Compatibility. Should be a Rack concern. --- actionpack/lib/action_controller/new_base/base.rb | 8 ++------ actionpack/lib/action_controller/new_base/compatibility.rb | 6 ++++-- actionpack/lib/action_controller/new_base/renderer.rb | 13 ++----------- actionpack/lib/action_controller/new_base/testing.rb | 4 ++-- actionpack/lib/action_view/template/text.rb | 2 +- actionpack/test/controller/verification_test.rb | 2 +- actionpack/test/controller/webservice_test.rb | 4 ++-- actionpack/test/new_base/render_text_test.rb | 6 +++--- 8 files changed, 17 insertions(+), 28 deletions(-) diff --git a/actionpack/lib/action_controller/new_base/base.rb b/actionpack/lib/action_controller/new_base/base.rb index fae08c58b2..88686d29d0 100644 --- a/actionpack/lib/action_controller/new_base/base.rb +++ b/actionpack/lib/action_controller/new_base/base.rb @@ -110,11 +110,7 @@ module ActionController options = _normalize_options(action, options, &blk) super(options) end - - def render_to_body(options) - super || [" "] - end - + # Redirects the browser to the target specified in +options+. This parameter can take one of three forms: # # * Hash - The URL will be generated by calling url_for with the +options+. @@ -172,4 +168,4 @@ module ActionController super(url, status) end end -end \ No newline at end of file +end diff --git a/actionpack/lib/action_controller/new_base/compatibility.rb b/actionpack/lib/action_controller/new_base/compatibility.rb index 522a9fe23b..250e7f0dff 100644 --- a/actionpack/lib/action_controller/new_base/compatibility.rb +++ b/actionpack/lib/action_controller/new_base/compatibility.rb @@ -91,7 +91,9 @@ module ActionController options[:text] = nil if options[:nothing] == true - super + body = super + body = [' '] if body.blank? + body end def _handle_method_missing @@ -110,4 +112,4 @@ module ActionController response_body end end -end \ No newline at end of file +end diff --git a/actionpack/lib/action_controller/new_base/renderer.rb b/actionpack/lib/action_controller/new_base/renderer.rb index 71b79fbc42..59df3c51da 100644 --- a/actionpack/lib/action_controller/new_base/renderer.rb +++ b/actionpack/lib/action_controller/new_base/renderer.rb @@ -28,7 +28,7 @@ module ActionController _process_options(options) if options.key?(:text) - options[:_template] = ActionView::TextTemplate.new(_text(options), formats.first) + options[:_template] = ActionView::TextTemplate.new(options[:text], formats.first) elsif options.key?(:inline) handler = ActionView::Template.handler_class_for_extension(options[:type] || "erb") template = ActionView::Template.new(options[:inline], "inline #{options[:inline].inspect}", handler, {}) @@ -51,17 +51,8 @@ module ActionController def _prefix controller_path - end - - def _text(options) - text = options[:text] - - case text - when nil then " " - else text.to_s - end end - + def _render_partial(partial, options) case partial when true diff --git a/actionpack/lib/action_controller/new_base/testing.rb b/actionpack/lib/action_controller/new_base/testing.rb index 6a92c292bd..d8c3421587 100644 --- a/actionpack/lib/action_controller/new_base/testing.rb +++ b/actionpack/lib/action_controller/new_base/testing.rb @@ -7,7 +7,7 @@ module ActionController @_response = response @_response.request = request ret = process(request.parameters[:action]) - @_response.body ||= self.response_body || " " + @_response.body ||= self.response_body @_response.prepare! set_test_assigns ret @@ -27,4 +27,4 @@ module ActionController @_response.headers.replace(new_headers) end end -end \ No newline at end of file +end diff --git a/actionpack/lib/action_view/template/text.rb b/actionpack/lib/action_view/template/text.rb index 927a0d7a72..a86c3915c2 100644 --- a/actionpack/lib/action_view/template/text.rb +++ b/actionpack/lib/action_view/template/text.rb @@ -2,7 +2,7 @@ module ActionView #:nodoc: class TextTemplate < String #:nodoc: def initialize(string, content_type = Mime[:html]) - super(string) + super(string.to_s) @content_type = Mime[content_type] end diff --git a/actionpack/test/controller/verification_test.rb b/actionpack/test/controller/verification_test.rb index 85134a8264..d568030e41 100644 --- a/actionpack/test/controller/verification_test.rb +++ b/actionpack/test/controller/verification_test.rb @@ -182,7 +182,7 @@ class VerificationTest < ActionController::TestCase def test_unguarded_without_params get :unguarded - assert_equal "", @response.body + assert @response.body.blank? end def test_guarded_in_session_with_prereqs diff --git a/actionpack/test/controller/webservice_test.rb b/actionpack/test/controller/webservice_test.rb index e89d6bb960..9bf8da7276 100644 --- a/actionpack/test/controller/webservice_test.rb +++ b/actionpack/test/controller/webservice_test.rb @@ -34,7 +34,7 @@ class WebServiceTest < ActionController::IntegrationTest def test_check_parameters with_test_route_set do get "/" - assert_equal '', @controller.response.body + assert @controller.response.body.blank? end end @@ -163,7 +163,7 @@ class WebServiceTest < ActionController::IntegrationTest with_test_route_set do ActionController::Base.param_parsers[Mime::XML] = :xml_simple assert_nothing_raised { post "/", "", {'CONTENT_TYPE' => 'application/xml'} } - assert_equal "", @controller.response.body + assert @controller.response.body.blank? end end diff --git a/actionpack/test/new_base/render_text_test.rb b/actionpack/test/new_base/render_text_test.rb index 69594e4b64..aed903ee8a 100644 --- a/actionpack/test/new_base/render_text_test.rb +++ b/actionpack/test/new_base/render_text_test.rb @@ -88,14 +88,14 @@ module RenderText assert_status 404 end - test "rendering text with nil returns a single space character" do + test "rendering text with nil returns an empty body padded for Safari" do get "/render_text/with_layout/with_nil" assert_body " " assert_status 200 end - test "Rendering text with nil and custom status code returns a single space character with the status" do + test "Rendering text with nil and custom status code returns an empty body padded for Safari and the status" do get "/render_text/with_layout/with_nil_and_status" assert_body " " @@ -139,4 +139,4 @@ module RenderText end end -ActionController::Base.app_loaded! \ No newline at end of file +ActionController::Base.app_loaded! -- cgit v1.2.3