rails/rails — pull request #8969 by wezm (2013-01-16 22:27:44+00:00)
Title: Fix handling of multiple cookies in rails 2.3

Rails 2.3.15 increased the required rack version to 1.1.3, this brought
in [some changes to the way multiple cookies are handled](https://github.com/rack/rack/commit/7754cdb5f5fa937ed3e1a811680f349d0acba73d) in a response.
Previously they were stored as an Array but now they are stored as a
String.

As a result of this there is a failing test, test_multiple_cookies(CookieTest)
[actionpack/test/controller/cookie_test.rb:125]. This change fixes the
test and also resolves the original issue I encountered.

The original issue was failing integration tests (under ruby 1.8) due to
a stray new line being added to the cookie string. This in turn resulted
in an empty string being included in the cookies array when it was split
in [ActionController::Integration::Session](https://github.com/rails/rails/blob/2-3-stable/actionpack/lib/action_controller/integration.rb#L328).

For example a the cookie string would go from:

cookie1=aaa\ncookie2=bbb

to:

cookie1=aaa\n\ncookie2=bbb

resulting in `cookies` being set to `["cookie1=aaa", "", "cookie2=bbb"]`
in Integration::Session, which would subsequently cause an exception to
be raised when the empty [string was split on line 330](https://github.com/rails/rails/blob/2-3-stable/actionpack/lib/action_controller/integration.rb#L330).

The stray new line is introduced by convert_cookies! in
ActionController::Response. The use of Kernel#Array in ruby 1.8 was
splitting the string on new lines but does not consume the new line, so
when the array is eventually joined back into a string extra new lines
are present.

In ruby 1.9 Kernel#Array no longer splits, thus the test failed because
it was expecting multiple cookies but only getting one.