Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #3581 from amatsuda/metal_response_body_19

AC::Metal#response_body= stores different value in Ruby 1.8 and 1.9
  • Loading branch information...
commit d2cfa982fde089c4f74f830c9c02891c93cf21e5 2 parents a625523 + be7ab83
@josevalim josevalim authored
View
8 actionpack/lib/action_controller/metal.rb
@@ -182,7 +182,13 @@ def status=(status)
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
6 actionpack/test/controller/new_base/bare_metal_test.rb
@@ -23,6 +23,12 @@ class BareTest < ActiveSupport::TestCase
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
Please sign in to comment.
Something went wrong with that request. Please try again.