aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-11-10 00:49:14 -0800
committerJosé Valim <jose.valim@gmail.com>2011-11-10 00:49:14 -0800
commitd2cfa982fde089c4f74f830c9c02891c93cf21e5 (patch)
tree589afa6ee972cf1ba8a529dce06207c2f20751e7
parenta625523e755421b0f96fe5b0a885462ef51582b1 (diff)
parentbe7ab83b647c1ebb619b88854d310497075ea58f (diff)
downloadrails-d2cfa982fde089c4f74f830c9c02891c93cf21e5.tar.gz
rails-d2cfa982fde089c4f74f830c9c02891c93cf21e5.tar.bz2
rails-d2cfa982fde089c4f74f830c9c02891c93cf21e5.zip
Merge pull request #3581 from amatsuda/metal_response_body_19
AC::Metal#response_body= stores different value in Ruby 1.8 and 1.9
-rw-r--r--actionpack/lib/action_controller/metal.rb8
-rw-r--r--actionpack/test/controller/new_base/bare_metal_test.rb6
2 files changed, 13 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/metal.rb b/actionpack/lib/action_controller/metal.rb
index 0133b2ecbc..125dbf6bb5 100644
--- a/actionpack/lib/action_controller/metal.rb
+++ b/actionpack/lib/action_controller/metal.rb
@@ -182,7 +182,13 @@ module ActionController
end
def response_body=(val)
- body = val.nil? ? nil : (val.respond_to?(:each) ? val : [val])
+ body = if val.is_a?(String)
+ [val]
+ elsif val.nil? || val.respond_to?(:each)
+ val
+ else
+ [val]
+ end
super body
end
diff --git a/actionpack/test/controller/new_base/bare_metal_test.rb b/actionpack/test/controller/new_base/bare_metal_test.rb
index 3ca29f1bcf..c424dcbd8d 100644
--- a/actionpack/test/controller/new_base/bare_metal_test.rb
+++ b/actionpack/test/controller/new_base/bare_metal_test.rb
@@ -23,6 +23,12 @@ module BareMetalTest
assert_equal "Hello world", string
end
+
+ test "response_body value is wrapped in an array when the value is a String" do
+ controller = BareController.new
+ controller.index
+ assert_equal ["Hello world"], controller.response_body
+ end
end
class HeadController < ActionController::Metal