Skip to content

Commit

Permalink
with_output_buffer cannot assume there's an output_buffer
Browse files Browse the repository at this point in the history
[#4182 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information
fxn authored and jeremy committed Mar 15, 2010
1 parent c937da9 commit a594a22
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/helpers/capture_helper.rb
Expand Up @@ -140,7 +140,7 @@ def content_for?(name)
def with_output_buffer(buf = nil) #:nodoc:
unless buf
buf = ActionView::OutputBuffer.new
buf.force_encoding(output_buffer.encoding) if buf.respond_to?(:force_encoding)
buf.force_encoding(output_buffer.encoding) if output_buffer && buf.respond_to?(:force_encoding)
end
self.output_buffer, old_buffer = buf, output_buffer
yield
Expand Down
6 changes: 6 additions & 0 deletions actionpack/test/template/capture_helper_test.rb
Expand Up @@ -12,4 +12,10 @@ def test_content_for
assert content_for?(:title)
assert ! content_for?(:something_else)
end

def test_with_output_buffer_does_not_assume_there_is_an_output_buffer
av = ActionView::Base.new
assert_nil av.output_buffer
assert_equal "", av.with_output_buffer {}
end
end

0 comments on commit a594a22

Please sign in to comment.