Merge pull request #29951 from georgeclaghorn/action-view-test-flow

Fix testing helpers that use Action View's capturing helpers (e.g. content_for)
This commit is contained in:
Kasper Timm Hansen 2017-07-30 16:13:47 +02:00 committed by GitHub
commit f757c1f413
2 changed files with 10 additions and 0 deletions

View File

@ -103,6 +103,7 @@ module ActionView
def setup_with_controller
@controller = ActionView::TestCase::TestController.new
@request = @controller.request
@view_flow = ActionView::OutputFlow.new
# empty string ensures buffer has UTF-8 encoding as
# new without arguments returns ASCII-8BIT encoded buffer like String#new
@output_buffer = ActiveSupport::SafeBuffer.new ""
@ -246,6 +247,7 @@ module ActionView
:@test_passed,
:@view,
:@view_context_class,
:@view_flow,
:@_subscribers,
:@html_document
]

View File

@ -282,6 +282,14 @@ module ActionView
@customers = [DeveloperStruct.new("Eloy"), DeveloperStruct.new("Manfred")]
assert_match(/Hello: EloyHello: Manfred/, render(file: "test/list"))
end
test "is able to use helpers that depend on the view flow" do
assert_not content_for?(:foo)
content_for :foo, "bar"
assert content_for?(:foo)
assert_equal "bar", content_for(:foo)
end
end
class AssertionsTest < ActionView::TestCase