Move Safari response-padding fix to Rails2Compatibility. Should be a Rack concern.

This commit is contained in:
Jeremy Kemper 2009-05-21 20:22:18 -07:00
parent 8f3cbb4773
commit 4c52ba278b
8 changed files with 17 additions and 28 deletions

@ -110,11 +110,7 @@ def render_to_string(action = nil, options = {}, &blk)
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:
#
# * <tt>Hash</tt> - The URL will be generated by calling url_for with the +options+.
@ -172,4 +168,4 @@ def redirect_to(options = {}, response_status = {}) #:doc:
super(url, status)
end
end
end
end

@ -91,7 +91,9 @@ def render_to_body(options)
options[:text] = nil if options[:nothing] == true
super
body = super
body = [' '] if body.blank?
body
end
def _handle_method_missing
@ -110,4 +112,4 @@ def performed?
response_body
end
end
end
end

@ -28,7 +28,7 @@ def render_to_body(options)
_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 @@ def render_to_body(options)
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

@ -7,7 +7,7 @@ def process_with_new_base_test(request, response)
@_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 @@ def headers=(new_headers)
@_response.headers.replace(new_headers)
end
end
end
end

@ -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

@ -182,7 +182,7 @@ def test_unguarded_with_params
def test_unguarded_without_params
get :unguarded
assert_equal "", @response.body
assert @response.body.blank?
end
def test_guarded_in_session_with_prereqs

@ -34,7 +34,7 @@ def teardown
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 @@ def test_use_xml_ximple_with_empty_request
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

@ -88,14 +88,14 @@ class RenderTextTest < SimpleRouteCase
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 @@ class RenderTextTest < SimpleRouteCase
end
end
ActionController::Base.app_loaded!
ActionController::Base.app_loaded!