From 49306ccacf01e36d444771d42321965616e226f0 Mon Sep 17 00:00:00 2001 From: mark Date: Thu, 11 Dec 2008 11:06:35 -0600 Subject: Add :partial option to assert_template [#1550 state:resolved] Signed-off-by: Joshua Peek --- actionpack/lib/action_view/test_case.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'actionpack/lib/action_view/test_case.rb') diff --git a/actionpack/lib/action_view/test_case.rb b/actionpack/lib/action_view/test_case.rb index 4ab4ed233f..a5655843d2 100644 --- a/actionpack/lib/action_view/test_case.rb +++ b/actionpack/lib/action_view/test_case.rb @@ -1,4 +1,24 @@ module ActionView + class Base + alias_method :initialize_without_template_tracking, :initialize + def initialize(*args) + @_rendered = { :template => nil, :partials => Hash.new(0) } + initialize_without_template_tracking(*args) + end + end + + module Renderable + alias_method :render_without_template_tracking, :render + def render(view, local_assigns = {}) + if respond_to?(:path) && !is_a?(InlineTemplate) + rendered = view.instance_variable_get(:@_rendered) + rendered[:partials][self] += 1 if is_a?(RenderablePartial) + rendered[:template] ||= self + end + render_without_template_tracking(view, local_assigns) + end + end + class TestCase < ActiveSupport::TestCase include ActionController::TestCase::Assertions -- cgit v1.2.3