1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Memoize the object returned by _view in ActionView::TestCase::Behavior

[#4799 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
David Chelimsky 2010-06-08 15:18:02 -04:00 committed by José Valim
parent ab2877cbe8
commit bdcf70cca8
2 changed files with 12 additions and 6 deletions

View file

@ -131,12 +131,14 @@ module ActionView
end end
def _view def _view
view = ActionView::Base.new(ActionController::Base.view_paths, _assigns, @controller) @_view ||= begin
view.singleton_class.send :include, _helpers view = ActionView::Base.new(ActionController::Base.view_paths, _assigns, @controller)
view.singleton_class.send :include, @controller._router.url_helpers view.singleton_class.send :include, _helpers
view.singleton_class.send :delegate, :alert, :notice, :to => "request.flash" view.singleton_class.send :include, @controller._router.url_helpers
view.output_buffer = self.output_buffer view.singleton_class.send :delegate, :alert, :notice, :to => "request.flash"
view view.output_buffer = self.output_buffer
view
end
end end
EXCLUDE_IVARS = %w{ EXCLUDE_IVARS = %w{

View file

@ -37,6 +37,10 @@ module ActionView
include SharedTests include SharedTests
test_case = self test_case = self
test "memoizes the _view" do
assert_same _view, _view
end
test "works without testing a helper module" do test "works without testing a helper module" do
assert_equal 'Eloy', render('developers/developer', :developer => stub(:name => 'Eloy')) assert_equal 'Eloy', render('developers/developer', :developer => stub(:name => 'Eloy'))
end end