diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-04-26 20:24:53 -0300 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-04-29 14:45:05 -0300 |
commit | e72374d0ff8b149bdbf8e14a703cbc2028df520c (patch) | |
tree | dbf0b6446d2a7b8ae421169908fff8ddcd524d3f /actionpack/test | |
parent | 82029c7511939074c7f50a415016fb2910c5d95e (diff) | |
download | rails-e72374d0ff8b149bdbf8e14a703cbc2028df520c.tar.gz rails-e72374d0ff8b149bdbf8e14a703cbc2028df520c.tar.bz2 rails-e72374d0ff8b149bdbf8e14a703cbc2028df520c.zip |
Allow layout rendering to access current object being rendered when using partial + collection
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/fixtures/test/_b_layout_for_partial_with_object.html.erb | 1 | ||||
-rw-r--r-- | actionpack/test/template/render_test.rb | 8 |
2 files changed, 7 insertions, 2 deletions
diff --git a/actionpack/test/fixtures/test/_b_layout_for_partial_with_object.html.erb b/actionpack/test/fixtures/test/_b_layout_for_partial_with_object.html.erb new file mode 100644 index 0000000000..bdd53014cd --- /dev/null +++ b/actionpack/test/fixtures/test/_b_layout_for_partial_with_object.html.erb @@ -0,0 +1 @@ +<b class="<%= customer.name.downcase %>"><%= yield %></b>
\ No newline at end of file diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index 43b176df3c..5fe725ec31 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -233,11 +233,15 @@ module RenderTestCases def test_render_partial_with_nil_values_in_collection assert_equal "Hello: davidHello: Anonymous", @view.render(:partial => "test/customer", :collection => [ Customer.new("david"), nil ]) end - + def test_render_partial_with_layout_using_collection_and_template assert_equal "<b>Hello: Amazon</b><b>Hello: Yahoo</b>", @view.render(:partial => "test/customer", :layout => 'test/b_layout_for_partial', :collection => [ Customer.new("Amazon"), Customer.new("Yahoo") ]) end + def test_render_partial_with_layout_using_collection_and_template_makes_current_item_available_in_template + assert_equal '<b class="amazon">Hello: Amazon</b><b class="yahoo">Hello: Yahoo</b>', @view.render(:partial => "test/customer", :layout => 'test/b_layout_for_partial_with_object', :collection => [ Customer.new("Amazon"), Customer.new("Yahoo") ]) + end + def test_render_partial_with_empty_array_should_return_nil assert_nil @view.render(:partial => []) end @@ -310,7 +314,7 @@ module RenderTestCases ActionView::Template.register_template_handler :foo, CustomHandler assert_equal 'source: "Hello, <%= name %>!"', @view.render(:inline => "Hello, <%= name %>!", :locals => { :name => "Josh" }, :type => :foo) end - + def test_render_knows_about_types_registered_when_extensions_are_checked_earlier_in_initialization ActionView::Template::Handlers.extensions ActionView::Template.register_template_handler :foo, CustomHandler |