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

Improve PartialTemplate tests

This commit is contained in:
Pratik Naik 2008-05-02 10:45:08 +01:00
parent b88a6dbc39
commit 87ec72bd8c
4 changed files with 13 additions and 7 deletions

View file

@ -242,9 +242,7 @@ If you are rendering a subtemplate, you must now use controller-like partial syn
END_ERROR
end
template = Template.new(self, template_path, use_full_path, local_assigns)
render_template(template)
Template.new(self, template_path, use_full_path, local_assigns).render_template
end
# Renders the template present at <tt>template_path</tt> (relative to the view_paths array).

View file

@ -24,10 +24,12 @@ module ActionView #:nodoc:
def render_member(object)
@locals[@counter_name] += 1
@locals[:object] = @locals[@variable_name] = object
returning render_template do
@locals.delete(@variable_name)
@locals.delete(:object)
end
template = render_template
@locals.delete(@variable_name)
@locals.delete(:object)
template
end
def counter=(num)

View file

@ -0,0 +1 @@
<%= doesnt_exist %>

View file

@ -51,6 +51,11 @@ class TemplateObjectTest < Test::Unit::TestCase
assert template.locals.has_key?(:partial_only)
end
def test_partial_with_errors
template = ActionView::PartialTemplate.new(@view, 'test/raise', nil)
assert_raise(ActionView::TemplateError) { template.render_template }
end
uses_mocha 'Partial template preparation tests' do
def test_should_prepare_on_initialization
ActionView::PartialTemplate.any_instance.expects(:prepare!)