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:
parent
b88a6dbc39
commit
87ec72bd8c
4 changed files with 13 additions and 7 deletions
|
@ -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).
|
||||||
|
|
|
@ -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)
|
||||||
|
|
1
actionpack/test/fixtures/test/_raise.html.erb
vendored
Normal file
1
actionpack/test/fixtures/test/_raise.html.erb
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<%= doesnt_exist %>
|
|
@ -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!)
|
||||||
|
|
Loading…
Reference in a new issue