From 3dfaedda9144b3e619c54576976ff67f33c8575e Mon Sep 17 00:00:00 2001 From: Cameron Yule Date: Thu, 7 Aug 2008 08:18:13 +0100 Subject: [PATCH] Adding tests for partial collection counters --- actionpack/test/controller/new_render_test.rb | 9 +++++++++ actionpack/test/fixtures/test/_counter.html.erb | 1 + actionpack/test/template/render_test.rb | 4 ++++ 3 files changed, 14 insertions(+), 0 deletions(-) create mode 100644 actionpack/test/fixtures/test/_counter.html.erb diff --git a/actionpack/test/controller/new_render_test.rb b/actionpack/test/controller/new_render_test.rb index d2a3a2b..eb0065c 100644 --- a/actionpack/test/controller/new_render_test.rb +++ b/actionpack/test/controller/new_render_test.rb @@ -136,6 +136,10 @@ class NewRenderTestController < ActionController::Base render :partial => "partial_only", :layout => true end + def partial_with_counter + render :partial => "counter", :locals => { :counter_counter => 5 } + end + def partial_with_locals render :partial => "customer", :locals => { :customer => Customer.new("david") } end @@ -740,6 +744,11 @@ EOS get :action_talk_to_layout assert_equal "Talking to the layout\nAction was here!", @response.body end + + def test_partial_with_counter + get :partial_with_counter + assert_equal "5", @response.body + end def test_partials_list get :partials_list diff --git a/actionpack/test/fixtures/test/_counter.html.erb b/actionpack/test/fixtures/test/_counter.html.erb new file mode 100644 index 0000000..fd245bf --- /dev/null +++ b/actionpack/test/fixtures/test/_counter.html.erb @@ -0,0 +1 @@ +<%= counter_counter %> \ No newline at end of file diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index b1af043..fb774f3 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -46,6 +46,10 @@ class ViewRenderTest < Test::Unit::TestCase def test_render_partial assert_equal "only partial", @view.render(:partial => "test/partial_only") end + + def test_render_partial_with_locals + assert_equal "5", @view.render(:partial => "test/counter", :locals => { :counter_counter => 5 }) + end def test_render_partial_with_errors assert_raise(ActionView::TemplateError) { @view.render(:partial => "test/raise") } -- 1.5.6.4