Previously, when content_for is flushed, the content
was replaced directly by a new value in
ActionView::OutputFlow#set. The problem is this new
value passed to the method may not be an instance of
ActiveSupport::SafeBuffer.
This change forces the value to be set to a new
instance of ActiveSupport::SafeBuffer.
This has been discussed in #17661 and partially reverts the changes made
in 9de83050d3 and 986cac73e3
The test case added to content_for acts as a regression / acceptance test.