From 2faf35cea9846fdfa1099f5dfd1589d53a3daf3b Mon Sep 17 00:00:00 2001 From: Cameron Yule Date: Sat, 9 Aug 2008 10:34:19 -0500 Subject: Added tests for partial collection counters [#766 state:resolved] Signed-off-by: Joshua Peek --- actionpack/test/controller/new_render_test.rb | 9 +++++++++ actionpack/test/fixtures/test/_counter.html.erb | 1 + actionpack/test/template/render_test.rb | 12 ++++++++---- 3 files changed, 18 insertions(+), 4 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 d2a3a2b0b0..be99350cd2 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 @@ -741,6 +745,11 @@ EOS 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 assert_equal "goodbyeHello: davidHello: marygoodbye\n", @response.body diff --git a/actionpack/test/fixtures/test/_counter.html.erb b/actionpack/test/fixtures/test/_counter.html.erb new file mode 100644 index 0000000000..fd245bfc70 --- /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 b1af043099..c37bac95f1 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -47,6 +47,10 @@ class ViewRenderTest < Test::Unit::TestCase 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") } end @@ -54,14 +58,14 @@ class ViewRenderTest < Test::Unit::TestCase def test_render_partial_collection assert_equal "Hello: davidHello: mary", @view.render(:partial => "test/customer", :collection => [ Customer.new("david"), Customer.new("mary") ]) end - + def test_render_partial_collection_as - assert_equal "david david davidmary mary mary", + assert_equal "david david davidmary mary mary", @view.render(:partial => "test/customer_with_var", :collection => [ Customer.new("david"), Customer.new("mary") ], :as => :customer) end - + def test_render_partial_collection_without_as - assert_equal "local_inspector,local_inspector_counter,object", + assert_equal "local_inspector,local_inspector_counter,object", @view.render(:partial => "test/local_inspector", :collection => [ Customer.new("mary") ]) end -- cgit v1.2.3