Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Memoize the object returned by _view in ActionView::TestCase::Behavior
[rails#4799 state:resolved]
  • Loading branch information
dchelimsky committed Jun 8, 2010
1 parent d103c73 commit 890dd10
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 8 additions & 6 deletions actionpack/lib/action_view/test_case.rb
Expand Up @@ -131,12 +131,14 @@ def make_test_case_available_to_view!
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{
Expand Down
4 changes: 4 additions & 0 deletions actionpack/test/template/test_case_test.rb
Expand Up @@ -37,6 +37,10 @@ class GeneralViewTest < ActionView::TestCase
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
Expand Down

0 comments on commit 890dd10

Please sign in to comment.