1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Revert "Re-enable capture'ing non-String values"

This reverts commit c2fe0938d7.
This commit is contained in:
Santiago Pastorino 2014-12-15 21:20:54 -02:00
parent 488aefe742
commit e4627edf87
4 changed files with 3 additions and 15 deletions

View file

@ -1,8 +1 @@
Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/actionview/CHANGELOG.md) for previous changes.
* Restore old behaviour for `capture` to return value as is when passed non-String values.
Fixes #17661.
*Carsten Zimmermann*

View file

@ -36,7 +36,7 @@ module ActionView
def capture(*args)
value = nil
buffer = with_output_buffer { value = yield(*args) }
if string = buffer.presence || value
if string = buffer.presence || value and string.is_a?(String)
ERB::Util.html_escape string
end
end

View file

@ -24,8 +24,8 @@ class CaptureHelperTest < ActionView::TestCase
assert_equal 'foobar', string
end
def test_capture_returns_value_even_if_the_returned_value_is_not_a_string
assert_equal '1', @av.capture { 1 }
def test_capture_returns_nil_if_the_returned_value_is_not_a_string
assert_nil @av.capture { 1 }
end
def test_capture_escapes_html

View file

@ -64,11 +64,6 @@ class TagHelperTest < ActionView::TestCase
content_tag("a", "href" => "create") { "Create" }
end
def test_content_tag_with_block_and_non_string_outside_out_of_erb
assert_equal content_tag("p", "1.0", nil, false),
content_tag("p") { 1.0 }
end
def test_content_tag_nested_in_content_tag_out_of_erb
assert_equal content_tag("p", content_tag("b", "Hello")),
content_tag("p") { content_tag("b", "Hello") },