aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/naming_test.rb
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-11-23 19:06:45 +0000
committerJosé Valim <jose.valim@gmail.com>2011-11-23 19:06:45 +0000
commitfd86a1b6b068df87164d5763bdcd4a323a1e76f4 (patch)
tree559eecb04f11df12756b9c43018cef32ef3ce3ef /activemodel/test/cases/naming_test.rb
parent3ee0116c949dfc5760d60fe9c77168fb3868a4ec (diff)
downloadrails-fd86a1b6b068df87164d5763bdcd4a323a1e76f4.tar.gz
rails-fd86a1b6b068df87164d5763bdcd4a323a1e76f4.tar.bz2
rails-fd86a1b6b068df87164d5763bdcd4a323a1e76f4.zip
Rely on a public contract between railties instead of accessing railtie methods directly.
Diffstat (limited to 'activemodel/test/cases/naming_test.rb')
-rw-r--r--activemodel/test/cases/naming_test.rb38
1 files changed, 34 insertions, 4 deletions
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