Skip to content

Commit

Permalink
use Array#join so that file encoding doesn't impact returned string.
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Dec 13, 2011
1 parent 25ac7e4 commit 4371be2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions actionpack/lib/action_dispatch/http/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ def to_path
end

def body
str = ''
each { |part| str << part.to_s }
str
strings = []
each { |part| strings << part.to_s }
strings.join
end

EMPTY = " "
Expand Down
9 changes: 9 additions & 0 deletions actionpack/test/dispatch/response_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ def setup
@response = ActionDispatch::Response.new
end

def test_response_body_encoding
# FIXME: remove this conditional on Rails 4.0
return unless "<3".encoding_aware?

body = ["hello".encode('utf-8')]
response = ActionDispatch::Response.new 200, {}, body
assert_equal Encoding::UTF_8, response.body.encoding
end

test "simple output" do
@response.body = "Hello, World!"

Expand Down

0 comments on commit 4371be2

Please sign in to comment.