rails/rails — pull request #11623 by sorah (2013-07-27 15:44:10+00:00)
Title: Restore response.stream in render_to_string with ActionController::Live

Fix `render_to_string` in `ActionController::Live` to not break `response.stream`;
By wrapping `render_to_string` method to restore `response.stream` too.

Because `render_to_string` modifies `response_body` temporally, but
it doesn't restore `response.stream`.

This will work properly by this fix:

``` ruby
class FooController < ActionController::Base
include ActionController::Live

def streaming
response.stream.write "foo\n"

# This breaks existing response.stream before
render_to_string(partial: 'shared/foo')

# This will raise IOError because render_to_string re-news `response.stream`,
# and it has closed by `ActionController::Live#response_body=`
response.stream.write "bar\n"
response.stream.close
end
end
```

Confirmed this can reproduce at Rails 4.0.0 too.