From bdcf70cca89df906a3510464ef46a44646fd29a3 Mon Sep 17 00:00:00 2001 From: David Chelimsky Date: Tue, 8 Jun 2010 15:18:02 -0400 Subject: Memoize the object returned by _view in ActionView::TestCase::Behavior MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [#4799 state:resolved] Signed-off-by: José Valim --- actionpack/lib/action_view/test_case.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'actionpack/lib') 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{ -- cgit v1.2.3