Skip to content

Commit

Permalink
Revert "Re-enable capture'ing non-String values"
Browse files Browse the repository at this point in the history
This reverts commit c2fe093.
  • Loading branch information
spastorino committed Dec 15, 2014
1 parent 488aefe commit e4627ed
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 15 deletions.
7 changes: 0 additions & 7 deletions actionview/CHANGELOG.md
@@ -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*

2 changes: 1 addition & 1 deletion actionview/lib/action_view/helpers/capture_helper.rb
Expand Up @@ -36,7 +36,7 @@ module CaptureHelper
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
Expand Down
4 changes: 2 additions & 2 deletions actionview/test/template/capture_helper_test.rb
Expand Up @@ -24,8 +24,8 @@ def test_capture_captures_the_value_returned_by_the_block_if_the_temporary_buffe
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
Expand Down
5 changes: 0 additions & 5 deletions actionview/test/template/tag_helper_test.rb
Expand Up @@ -64,11 +64,6 @@ def test_content_tag_with_block_and_options_outside_out_of_erb
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") },
Expand Down

0 comments on commit e4627ed

Please sign in to comment.