aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view
diff options
context:
space:
mode:
authormark <mark@looking-glass.com>2008-12-11 11:06:35 -0600
committerJoshua Peek <josh@joshpeek.com>2008-12-11 11:06:35 -0600
commit49306ccacf01e36d444771d42321965616e226f0 (patch)
treebcd21d1a7e0ee6b6cbd80b1e9d1724b752e47a45 /actionpack/lib/action_view
parent5ede4ce188d29aef94af78f27d89169ac4ee54cd (diff)
downloadrails-49306ccacf01e36d444771d42321965616e226f0.tar.gz
rails-49306ccacf01e36d444771d42321965616e226f0.tar.bz2
rails-49306ccacf01e36d444771d42321965616e226f0.zip
Add :partial option to assert_template [#1550 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r--actionpack/lib/action_view/renderable.rb5
-rw-r--r--actionpack/lib/action_view/test_case.rb20
2 files changed, 20 insertions, 5 deletions
diff --git a/actionpack/lib/action_view/renderable.rb b/actionpack/lib/action_view/renderable.rb
index 7258ad04bf..7c0e62f1d7 100644
--- a/actionpack/lib/action_view/renderable.rb
+++ b/actionpack/lib/action_view/renderable.rb
@@ -28,11 +28,6 @@ module ActionView
stack = view.instance_variable_get(:@_render_stack)
stack.push(self)
- # This is only used for TestResponse to set rendered_template
- unless is_a?(InlineTemplate) || view.instance_variable_get(:@_first_render)
- view.instance_variable_set(:@_first_render, self)
- end
-
view.send(:_evaluate_assigns_and_ivars)
view.send(:_set_controller_content_type, mime_type) if respond_to?(:mime_type)
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