diff options
author | Grant Hutchins & Peter Jaros <pair+grant+pjaros@pivotallabs.com> | 2011-07-08 17:54:15 -0400 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2011-08-13 16:22:21 -0700 |
commit | 6e671a8536f17b6f23b5251652015ce8c1557f1f (patch) | |
tree | 98177efb062b64203d0b33122515fd7b72909392 /actionpack/test/template/render_test.rb | |
parent | a636a9358e184bd1a3e2d2522584247be7045cdf (diff) | |
download | rails-6e671a8536f17b6f23b5251652015ce8c1557f1f.tar.gz rails-6e671a8536f17b6f23b5251652015ce8c1557f1f.tar.bz2 rails-6e671a8536f17b6f23b5251652015ce8c1557f1f.zip |
Let ActiveModel instances define partial paths.
Deprecate ActiveModel::Name#partial_path. Now you
should call #to_path directly on ActiveModel
instances.
Diffstat (limited to 'actionpack/test/template/render_test.rb')
-rw-r--r-- | actionpack/test/template/render_test.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index 68b2ed45d1..0b91e55091 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -201,6 +201,36 @@ module RenderTestCases @controller_view.render(customers, :greeting => "Hello") end + class CustomerWithDeprecatedPartialPath + attr_reader :name + + def self.model_name + Struct.new(:partial_path).new("customers/customer") + end + + def initialize(name) + @name = name + end + end + + def test_render_partial_using_object_with_deprecated_partial_path + assert_deprecated(/#model_name.*#partial_path.*#to_path/) do + assert_equal "Hello: nertzy", + @controller_view.render(CustomerWithDeprecatedPartialPath.new("nertzy"), :greeting => "Hello") + end + end + + def test_render_partial_using_collection_with_deprecated_partial_path + assert_deprecated(/#model_name.*#partial_path.*#to_path/) do + customers = [ + CustomerWithDeprecatedPartialPath.new("nertzy"), + CustomerWithDeprecatedPartialPath.new("peeja") + ] + assert_equal "Hello: nertzyHello: peeja", + @controller_view.render(customers, :greeting => "Hello") + end + end + # TODO: The reason for this test is unclear, improve documentation def test_render_partial_and_fallback_to_layout assert_equal "Before (Josh)\n\nAfter", @view.render(:partial => "test/layout_for_partial", :locals => { :name => "Josh" }) |