mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
partial counters with :as [#2804 state:resolved]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
This commit is contained in:
committed by
Jeremy Kemper
parent
3436fdfc12
commit
fa99de0bd0
@@ -248,6 +248,7 @@ module ActionView
|
||||
|
||||
@collection.each do |object|
|
||||
locals[counter_name] += 1
|
||||
locals["#{as.to_s}_counter".to_sym] = locals[counter_name]
|
||||
locals[as] = object
|
||||
|
||||
segments << template.render(@view, locals)
|
||||
|
||||
@@ -547,6 +547,10 @@ class TestController < ActionController::Base
|
||||
render :partial => "customer_counter", :collection => [ Customer.new("david"), Customer.new("mary") ]
|
||||
end
|
||||
|
||||
def partial_collection_with_as_and_counter
|
||||
render :partial => "customer_counter_with_as", :collection => [ Customer.new("david"), Customer.new("mary") ], :as => :client
|
||||
end
|
||||
|
||||
def partial_collection_with_locals
|
||||
render :partial => "customer_greeting", :collection => [ Customer.new("david"), Customer.new("mary") ], :locals => { :greeting => "Bonjour" }
|
||||
end
|
||||
@@ -1242,6 +1246,11 @@ class RenderTest < ActionController::TestCase
|
||||
assert_equal "david0mary1", @response.body
|
||||
end
|
||||
|
||||
def test_partial_collection_with_as_and_counter
|
||||
get :partial_collection_with_as_and_counter
|
||||
assert_equal "david0mary1", @response.body
|
||||
end
|
||||
|
||||
def test_partial_collection_with_locals
|
||||
get :partial_collection_with_locals
|
||||
assert_equal "Bonjour: davidBonjour: mary", @response.body
|
||||
|
||||
1
actionpack/test/fixtures/test/_customer_counter_with_as.erb
vendored
Normal file
1
actionpack/test/fixtures/test/_customer_counter_with_as.erb
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<%= client.name %><%= client_counter %>
|
||||
Reference in New Issue
Block a user