Merge pull request #3581 from amatsuda/metal_response_body_19

AC::Metal#response_body= stores different value in Ruby 1.8 and 1.9
This commit is contained in:
José Valim
2011-11-10 00:49:14 -08:00
2 changed files with 13 additions and 1 deletions

View File

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

View File

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