提交 87ec72bd 编写于 作者: P Pratik Naik

Improve PartialTemplate tests

上级 b88a6dbc
...@@ -242,9 +242,7 @@ def render_file(template_path, use_full_path = true, local_assigns = {}) #:nodoc ...@@ -242,9 +242,7 @@ def render_file(template_path, use_full_path = true, local_assigns = {}) #:nodoc
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).
......
...@@ -24,10 +24,12 @@ def render ...@@ -24,10 +24,12 @@ def render
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)
......
<%= doesnt_exist %>
\ No newline at end of file
...@@ -51,6 +51,11 @@ def test_should_create_valid_partial_template ...@@ -51,6 +51,11 @@ def test_should_create_valid_partial_template
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!)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册