diff options
author | José Valim <jose.valim@gmail.com> | 2011-07-28 00:50:07 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-07-28 00:50:07 -0700 |
commit | 1b7db58a0604b01cd5c3a8d73b11158a48e45772 (patch) | |
tree | 69e237be48cc87fecce85c3e3c9cde1f844814d9 /activemodel/test/cases | |
parent | 8248052ee74465abfae5b202270e96c9fd93e785 (diff) | |
parent | bf812074fd55e7dcfa426d6c9bfd4d8d68922194 (diff) | |
download | rails-1b7db58a0604b01cd5c3a8d73b11158a48e45772.tar.gz rails-1b7db58a0604b01cd5c3a8d73b11158a48e45772.tar.bz2 rails-1b7db58a0604b01cd5c3a8d73b11158a48e45772.zip |
Merge pull request #2034 from Casecommons/to_path
Allow ActiveModel-compatible instances to define their own partial paths
Diffstat (limited to 'activemodel/test/cases')
-rw-r--r-- | activemodel/test/cases/conversion_test.rb | 9 | ||||
-rw-r--r-- | activemodel/test/cases/naming_test.rb | 16 |
2 files changed, 20 insertions, 5 deletions
diff --git a/activemodel/test/cases/conversion_test.rb b/activemodel/test/cases/conversion_test.rb index 7669bf5f65..2eccc4e56d 100644 --- a/activemodel/test/cases/conversion_test.rb +++ b/activemodel/test/cases/conversion_test.rb @@ -1,5 +1,6 @@ require 'cases/helper' require 'models/contact' +require 'models/helicopter' class ConversionTest < ActiveModel::TestCase test "to_model default implementation returns self" do @@ -22,4 +23,10 @@ class ConversionTest < ActiveModel::TestCase test "to_param default implementation returns a string of ids for persisted records" do assert_equal "1", Contact.new(:id => 1).to_param end -end
\ No newline at end of file + + test "to_path default implementation returns a string giving a relative path" do + assert_equal "contacts/contact", Contact.new.to_path + assert_equal "helicopters/helicopter", Helicopter.new.to_path, + "ActiveModel::Conversion#to_path caching should be class-specific" + end +end diff --git a/activemodel/test/cases/naming_test.rb b/activemodel/test/cases/naming_test.rb index f814fcc56c..bafe4f3c0c 100644 --- a/activemodel/test/cases/naming_test.rb +++ b/activemodel/test/cases/naming_test.rb @@ -26,7 +26,9 @@ class NamingTest < ActiveModel::TestCase end def test_partial_path - assert_equal 'post/track_backs/track_back', @model_name.partial_path + assert_deprecated(/#partial_path.*#to_path/) do + assert_equal 'post/track_backs/track_back', @model_name.partial_path + end end def test_human @@ -56,7 +58,9 @@ class NamingWithNamespacedModelInIsolatedNamespaceTest < ActiveModel::TestCase end def test_partial_path - assert_equal 'blog/posts/post', @model_name.partial_path + assert_deprecated(/#partial_path.*#to_path/) do + assert_equal 'blog/posts/post', @model_name.partial_path + end end def test_human @@ -98,7 +102,9 @@ class NamingWithNamespacedModelInSharedNamespaceTest < ActiveModel::TestCase end def test_partial_path - assert_equal 'blog/posts/post', @model_name.partial_path + assert_deprecated(/#partial_path.*#to_path/) do + assert_equal 'blog/posts/post', @model_name.partial_path + end end def test_human @@ -136,7 +142,9 @@ class NamingWithSuppliedModelNameTest < ActiveModel::TestCase end def test_partial_path - assert_equal 'articles/article', @model_name.partial_path + assert_deprecated(/#partial_path.*#to_path/) do + assert_equal 'articles/article', @model_name.partial_path + end end def test_human |