Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix tests on 1.8 by explicitly checking for strings (which also impro…

…ves performance).
  • Loading branch information...
commit d31af44012a6ba3ac5dbec45417ae9bfb5454d8c 1 parent 356dacb
@josevalim josevalim authored
Showing with 9 additions and 1 deletion.
  1. +9 −1 actionpack/lib/action_dispatch/http/response.rb
View
10 actionpack/lib/action_dispatch/http/response.rb
@@ -118,7 +118,15 @@ def body
def body=(body)
@blank = true if body == EMPTY
- @body = body.respond_to?(:each) ? body : [body]
+
+ # Explicitly check for strings. This is *wrong* theoretically
+ # but if we don't check this, the performance on string bodies
+ # is bad on Ruby 1.8 (because strings responds to each then).
+ @body = if body.respond_to?(:to_str) || !body.respond_to?(:each)
+ [body]
+ else
+ body
+ end
end
def body_parts

2 comments on commit d31af44

@tilsammans

Any plans on requiring 1.9.2+ from Rails version 3.2 onwards?

@josevalim
Owner

On 4.0.

Please sign in to comment.
Something went wrong with that request. Please try again.