Restore implicit to_s for content_for and provide

This commit is contained in:
Étienne Barrié 2021-05-07 11:27:48 -04:00
parent 226f22e843
commit f55f923a5f
2 changed files with 5 additions and 5 deletions

View File

@ -17,12 +17,12 @@ module ActionView
# Called by each renderer object to set the layout contents.
def set(key, value)
@content[key] = ActiveSupport::SafeBuffer.new(value)
@content[key] = ActiveSupport::SafeBuffer.new(value.to_s)
end
# Called by content_for
def append(key, value)
@content[key] << value
@content[key] << value.to_s
end
alias_method :append!, :append
end

View File

@ -51,14 +51,14 @@ class CaptureHelperTest < ActionView::TestCase
def test_content_for_with_multiple_calls
assert_not content_for?(:title)
content_for :title, "foo"
content_for :title, "bar"
content_for :title, :bar
assert_equal "foobar", content_for(:title)
end
def test_content_for_with_multiple_calls_and_flush
assert_not content_for?(:title)
content_for :title, "foo"
content_for :title, "bar", flush: true
content_for :title, :bar, flush: true
assert_equal "bar", content_for(:title)
end
@ -172,7 +172,7 @@ class CaptureHelperTest < ActionView::TestCase
assert_equal "hi&lt;p&gt;title&lt;/p&gt;", content_for(:title)
@view_flow = ActionView::OutputFlow.new
provide :title, "hi"
provide :title, :hi
provide :title, raw("<p>title</p>")
assert_equal "hi<p>title</p>", content_for(:title)
end