1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Added tests for partial collection counters [#766 state:resolved]

Signed-off-by: Joshua Peek <josh@joshpeek.com>
This commit is contained in:
Cameron Yule 2008-08-09 10:34:19 -05:00 committed by Joshua Peek
parent ea0d036e31
commit 2faf35cea9
3 changed files with 18 additions and 4 deletions

View file

@ -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 "<title>Talking to the layout</title>\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

View file

@ -0,0 +1 @@
<%= counter_counter %>

View file

@ -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