diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2008-05-02 10:45:08 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-05-02 10:45:08 +0100 |
commit | 87ec72bd8c4b5d178ba7a41e605bc9a8e27f9e67 (patch) | |
tree | 786157113ebcfa2d13dce3ca452bcd3bcaf04a27 /actionpack | |
parent | b88a6dbc39fcaa12dc58d06d4222f2443f02a32a (diff) | |
download | rails-87ec72bd8c4b5d178ba7a41e605bc9a8e27f9e67.tar.gz rails-87ec72bd8c4b5d178ba7a41e605bc9a8e27f9e67.tar.bz2 rails-87ec72bd8c4b5d178ba7a41e605bc9a8e27f9e67.zip |
Improve PartialTemplate tests
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_view/base.rb | 4 | ||||
-rw-r--r-- | actionpack/lib/action_view/partial_template.rb | 10 | ||||
-rw-r--r-- | actionpack/test/fixtures/test/_raise.html.erb | 1 | ||||
-rw-r--r-- | actionpack/test/template/template_object_test.rb | 5 |
4 files changed, 13 insertions, 7 deletions
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index bfd1a0ee0d..17260f09c5 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -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). diff --git a/actionpack/lib/action_view/partial_template.rb b/actionpack/lib/action_view/partial_template.rb index ffcf258afe..1fb3aaee02 100644 --- a/actionpack/lib/action_view/partial_template.rb +++ b/actionpack/lib/action_view/partial_template.rb @@ -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) diff --git a/actionpack/test/fixtures/test/_raise.html.erb b/actionpack/test/fixtures/test/_raise.html.erb new file mode 100644 index 0000000000..68b08181d3 --- /dev/null +++ b/actionpack/test/fixtures/test/_raise.html.erb @@ -0,0 +1 @@ +<%= doesnt_exist %>
\ No newline at end of file diff --git a/actionpack/test/template/template_object_test.rb b/actionpack/test/template/template_object_test.rb index 7adcde421f..afb5c5cc16 100644 --- a/actionpack/test/template/template_object_test.rb +++ b/actionpack/test/template/template_object_test.rb @@ -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!) |