diff options
author | George Claghorn <george@basecamp.com> | 2017-07-25 22:27:11 -0400 |
---|---|---|
committer | George Claghorn <george@basecamp.com> | 2017-07-25 22:27:11 -0400 |
commit | 4fb518c28ce2b66ddb5483c07a2f185394ed80c4 (patch) | |
tree | 7bd925e03a399969201330e62e831ce66244003b | |
parent | 6f9b01c056cd2f3a4761baf78df207e1154f1b06 (diff) | |
download | rails-4fb518c28ce2b66ddb5483c07a2f185394ed80c4.tar.gz rails-4fb518c28ce2b66ddb5483c07a2f185394ed80c4.tar.bz2 rails-4fb518c28ce2b66ddb5483c07a2f185394ed80c4.zip |
Fix testing helpers that use Action View's capturing helpers (e.g. content_for)
-rw-r--r-- | actionview/lib/action_view/test_case.rb | 2 | ||||
-rw-r--r-- | actionview/test/template/test_case_test.rb | 8 |
2 files changed, 10 insertions, 0 deletions
diff --git a/actionview/lib/action_view/test_case.rb b/actionview/lib/action_view/test_case.rb index 8542978e34..efe8c87b9b 100644 --- a/actionview/lib/action_view/test_case.rb +++ b/actionview/lib/action_view/test_case.rb @@ -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 ] diff --git a/actionview/test/template/test_case_test.rb b/actionview/test/template/test_case_test.rb index f2f64ffa71..05e5f21ce4 100644 --- a/actionview/test/template/test_case_test.rb +++ b/actionview/test/template/test_case_test.rb @@ -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 |