Skip to content

Commit

Permalink
Added tests for partial collection counters [#766 state:resolved]
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Peek <josh@joshpeek.com>
  • Loading branch information
Cameron Yule authored and josh committed Aug 9, 2008
1 parent ea0d036 commit 2faf35c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
9 changes: 9 additions & 0 deletions actionpack/test/controller/new_render_test.rb
Expand Up @@ -136,6 +136,10 @@ def partial_only_with_layout
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
Expand Down Expand Up @@ -741,6 +745,11 @@ def test_action_talk_to_layout
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
Expand Down
1 change: 1 addition & 0 deletions actionpack/test/fixtures/test/_counter.html.erb
@@ -0,0 +1 @@
<%= counter_counter %>
12 changes: 8 additions & 4 deletions actionpack/test/template/render_test.rb
Expand Up @@ -47,21 +47,25 @@ 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") }
end

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

Expand Down

0 comments on commit 2faf35c

Please sign in to comment.