diff options
author | David Chelimsky <dchelimsky@gmail.com> | 2010-06-08 15:18:02 -0400 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-06-08 21:25:31 +0200 |
commit | bdcf70cca89df906a3510464ef46a44646fd29a3 (patch) | |
tree | df6f8312491ca8063e5917886811a512dcd45901 /actionpack | |
parent | ab2877cbe89e266ee986fc12e603abd93ac017ad (diff) | |
download | rails-bdcf70cca89df906a3510464ef46a44646fd29a3.tar.gz rails-bdcf70cca89df906a3510464ef46a44646fd29a3.tar.bz2 rails-bdcf70cca89df906a3510464ef46a44646fd29a3.zip |
Memoize the object returned by _view in ActionView::TestCase::Behavior
[#4799 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_view/test_case.rb | 14 | ||||
-rw-r--r-- | actionpack/test/template/test_case_test.rb | 4 |
2 files changed, 12 insertions, 6 deletions
diff --git a/actionpack/lib/action_view/test_case.rb b/actionpack/lib/action_view/test_case.rb index 4dbbd2eb6a..15d424be74 100644 --- a/actionpack/lib/action_view/test_case.rb +++ b/actionpack/lib/action_view/test_case.rb @@ -131,12 +131,14 @@ module ActionView end def _view - view = ActionView::Base.new(ActionController::Base.view_paths, _assigns, @controller) - view.singleton_class.send :include, _helpers - view.singleton_class.send :include, @controller._router.url_helpers - view.singleton_class.send :delegate, :alert, :notice, :to => "request.flash" - view.output_buffer = self.output_buffer - view + @_view ||= begin + view = ActionView::Base.new(ActionController::Base.view_paths, _assigns, @controller) + view.singleton_class.send :include, _helpers + view.singleton_class.send :include, @controller._router.url_helpers + view.singleton_class.send :delegate, :alert, :notice, :to => "request.flash" + view.output_buffer = self.output_buffer + view + end end EXCLUDE_IVARS = %w{ diff --git a/actionpack/test/template/test_case_test.rb b/actionpack/test/template/test_case_test.rb index 16e5ee4f72..9b50ea8a42 100644 --- a/actionpack/test/template/test_case_test.rb +++ b/actionpack/test/template/test_case_test.rb @@ -37,6 +37,10 @@ module ActionView include SharedTests test_case = self + test "memoizes the _view" do + assert_same _view, _view + end + test "works without testing a helper module" do assert_equal 'Eloy', render('developers/developer', :developer => stub(:name => 'Eloy')) end |