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
|
||||
|
||||
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).
|
||||
|
|
|
@ -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)
|
||||
|
|
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)
|
||||
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!)
|
||||
|
|
Loading…
Reference in a new issue