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_ERROR
end end
template = Template.new(self, template_path, use_full_path, local_assigns) Template.new(self, template_path, use_full_path, local_assigns).render_template
render_template(template)
end end
# Renders the template present at <tt>template_path</tt> (relative to the view_paths array). # 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) def render_member(object)
@locals[@counter_name] += 1 @locals[@counter_name] += 1
@locals[:object] = @locals[@variable_name] = object @locals[:object] = @locals[@variable_name] = object
returning render_template do
@locals.delete(@variable_name) template = render_template
@locals.delete(:object) @locals.delete(@variable_name)
end @locals.delete(:object)
template
end end
def counter=(num) 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) assert template.locals.has_key?(:partial_only)
end 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 uses_mocha 'Partial template preparation tests' do
def test_should_prepare_on_initialization def test_should_prepare_on_initialization
ActionView::PartialTemplate.any_instance.expects(:prepare!) ActionView::PartialTemplate.any_instance.expects(:prepare!)