From 8f600cd4f9433d83c1758590f2386384fbffa3ef Mon Sep 17 00:00:00 2001 From: Jeff Kreeftmeijer Date: Sat, 15 May 2010 14:06:39 +0200 Subject: [PATCH] partial counters with :as [#2804 state:resolved] --- actionpack/lib/action_view/partials.rb | 1 + actionpack/test/controller/render_test.rb | 9 +++++++++ .../fixtures/test/_customer_counter_with_as.erb | 1 + 3 files changed, 11 insertions(+), 0 deletions(-) create mode 100644 actionpack/test/fixtures/test/_customer_counter_with_as.erb diff --git a/actionpack/lib/action_view/partials.rb b/actionpack/lib/action_view/partials.rb index 2dfd267..02c4e9f 100644 --- a/actionpack/lib/action_view/partials.rb +++ b/actionpack/lib/action_view/partials.rb @@ -218,6 +218,7 @@ module ActionView ActionController::RecordIdentifier.partial_path(object, controller.class.controller_path) template = _pick_partial_template(_partial_path) local_assigns[template.counter_name] = index + local_assigns["#{as.to_s}_counter".to_sym] = local_assigns[template.counter_name] result = template.render_partial(self, object, local_assigns.dup, as) index += 1 result diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index 331683e..42f776c 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -652,6 +652,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 @@ -1470,6 +1474,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 diff --git a/actionpack/test/fixtures/test/_customer_counter_with_as.erb b/actionpack/test/fixtures/test/_customer_counter_with_as.erb new file mode 100644 index 0000000..1241eb6 --- /dev/null +++ b/actionpack/test/fixtures/test/_customer_counter_with_as.erb @@ -0,0 +1 @@ +<%= client.name %><%= client_counter %> \ No newline at end of file -- 1.6.4.1