From dc8773b19f61af2ba818d66923fc65e17bad6c20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 1 Aug 2011 11:42:00 +0200 Subject: Rename new method to_path to to_partial_path to avoid conflicts with File#to_path and similar. --- activemodel/test/cases/naming_test.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'activemodel/test/cases/naming_test.rb') diff --git a/activemodel/test/cases/naming_test.rb b/activemodel/test/cases/naming_test.rb index bafe4f3c0c..1777ce2aae 100644 --- a/activemodel/test/cases/naming_test.rb +++ b/activemodel/test/cases/naming_test.rb @@ -26,7 +26,7 @@ class NamingTest < ActiveModel::TestCase end def test_partial_path - assert_deprecated(/#partial_path.*#to_path/) do + assert_deprecated(/#partial_path.*#to_partial_path/) do assert_equal 'post/track_backs/track_back', @model_name.partial_path end end @@ -58,7 +58,7 @@ class NamingWithNamespacedModelInIsolatedNamespaceTest < ActiveModel::TestCase end def test_partial_path - assert_deprecated(/#partial_path.*#to_path/) do + assert_deprecated(/#partial_path.*#to_partial_path/) do assert_equal 'blog/posts/post', @model_name.partial_path end end @@ -102,7 +102,7 @@ class NamingWithNamespacedModelInSharedNamespaceTest < ActiveModel::TestCase end def test_partial_path - assert_deprecated(/#partial_path.*#to_path/) do + assert_deprecated(/#partial_path.*#to_partial_path/) do assert_equal 'blog/posts/post', @model_name.partial_path end end @@ -142,7 +142,7 @@ class NamingWithSuppliedModelNameTest < ActiveModel::TestCase end def test_partial_path - assert_deprecated(/#partial_path.*#to_path/) do + assert_deprecated(/#partial_path.*#to_partial_path/) do assert_equal 'articles/article', @model_name.partial_path end end -- cgit v1.2.3 From 4015080efda2258d1eca87c92fc4039192969657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?U=C4=A3is=20Ozols?= Date: Fri, 7 Oct 2011 16:42:44 +0300 Subject: One of the activemodel naming tests wasn't asserting anything. --- activemodel/test/cases/naming_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activemodel/test/cases/naming_test.rb') diff --git a/activemodel/test/cases/naming_test.rb b/activemodel/test/cases/naming_test.rb index 1777ce2aae..5f943729dd 100644 --- a/activemodel/test/cases/naming_test.rb +++ b/activemodel/test/cases/naming_test.rb @@ -148,7 +148,7 @@ class NamingWithSuppliedModelNameTest < ActiveModel::TestCase end def test_human - 'Article' + assert_equal 'Article', @model_name.human end def test_route_key -- cgit v1.2.3 From fd86a1b6b068df87164d5763bdcd4a323a1e76f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 23 Nov 2011 19:06:45 +0000 Subject: Rely on a public contract between railties instead of accessing railtie methods directly. --- activemodel/test/cases/naming_test.rb | 38 +++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) (limited to 'activemodel/test/cases/naming_test.rb') diff --git a/activemodel/test/cases/naming_test.rb b/activemodel/test/cases/naming_test.rb index 5f943729dd..a5ee2d6090 100644 --- a/activemodel/test/cases/naming_test.rb +++ b/activemodel/test/cases/naming_test.rb @@ -74,10 +74,6 @@ class NamingWithNamespacedModelInIsolatedNamespaceTest < ActiveModel::TestCase def test_param_key assert_equal 'post', @model_name.param_key end - - def test_recognizing_namespace - assert_equal 'Post', Blog::Post.model_name.instance_variable_get("@unnamespaced") - end end class NamingWithNamespacedModelInSharedNamespaceTest < ActiveModel::TestCase @@ -160,6 +156,40 @@ class NamingWithSuppliedModelNameTest < ActiveModel::TestCase end end +class NamingUsingRelativeModelNameTest < ActiveModel::TestCase + def setup + @model_name = Blog::Post.model_name + end + + def test_singular + assert_equal 'blog_post', @model_name.singular + end + + def test_plural + assert_equal 'blog_posts', @model_name.plural + end + + def test_element + assert_equal 'post', @model_name.element + end + + def test_collection + assert_equal 'blog/posts', @model_name.collection + end + + def test_human + assert_equal 'Post', @model_name.human + end + + def test_route_key + assert_equal 'posts', @model_name.route_key + end + + def test_param_key + assert_equal 'post', @model_name.param_key + end +end + class NamingHelpersTest < Test::Unit::TestCase def setup @klass = Contact -- cgit v1.2.3 From dc39af0a9a998938a969b214554db624dcdd9c85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ku=C5=BAma?= Date: Thu, 24 Nov 2011 15:50:21 +0100 Subject: make ActiveModel::Name fail gracefully with anonymous classes --- activemodel/test/cases/naming_test.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'activemodel/test/cases/naming_test.rb') diff --git a/activemodel/test/cases/naming_test.rb b/activemodel/test/cases/naming_test.rb index a5ee2d6090..6f9004da7f 100644 --- a/activemodel/test/cases/naming_test.rb +++ b/activemodel/test/cases/naming_test.rb @@ -247,3 +247,16 @@ class NamingHelpersTest < Test::Unit::TestCase ActiveModel::Naming.send(method, *args) end end + +class NameWithAnonymousClassTest < Test::Unit::TestCase + def test_anonymous_class_without_name_argument + assert_raises(ArgumentError) do + model_name = ActiveModel::Name.new(Class.new) + end + end + + def test_anonymous_class_with_name_argument + model_name = ActiveModel::Name.new(Class.new, nil, "Anonymous") + assert_equal "Anonymous", model_name + end +end -- cgit v1.2.3 From 9817a8b7d61c4c88592a940c824376bb84f59c1d Mon Sep 17 00:00:00 2001 From: Arun Agrawal Date: Sat, 26 Nov 2011 19:03:58 +0530 Subject: Warning removed unused variable --- activemodel/test/cases/naming_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activemodel/test/cases/naming_test.rb') diff --git a/activemodel/test/cases/naming_test.rb b/activemodel/test/cases/naming_test.rb index 6f9004da7f..e8db73ba52 100644 --- a/activemodel/test/cases/naming_test.rb +++ b/activemodel/test/cases/naming_test.rb @@ -251,7 +251,7 @@ end class NameWithAnonymousClassTest < Test::Unit::TestCase def test_anonymous_class_without_name_argument assert_raises(ArgumentError) do - model_name = ActiveModel::Name.new(Class.new) + ActiveModel::Name.new(Class.new) end end -- cgit v1.2.3