diff options
author | Yves Senn <yves.senn@garaio.com> | 2011-05-20 16:48:51 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@garaio.com> | 2011-05-20 16:59:09 +0200 |
commit | e5429b789db242950c39215b4e154bbc73034a28 (patch) | |
tree | e1979d7e05c8eeef558439b0fa163e66934e47fd /activemodel/test/cases | |
parent | 499825e19f961569d6ee72ca4b7e9d6b79164085 (diff) | |
download | rails-e5429b789db242950c39215b4e154bbc73034a28.tar.gz rails-e5429b789db242950c39215b4e154bbc73034a28.tar.bz2 rails-e5429b789db242950c39215b4e154bbc73034a28.zip |
Specify the name to be used for ActiveModel::Name fixes #1168
This patch allows to specify the name of your models independent of the class name.
Diffstat (limited to 'activemodel/test/cases')
-rw-r--r-- | activemodel/test/cases/naming_test.rb | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/activemodel/test/cases/naming_test.rb b/activemodel/test/cases/naming_test.rb index a7dde2c433..f814fcc56c 100644 --- a/activemodel/test/cases/naming_test.rb +++ b/activemodel/test/cases/naming_test.rb @@ -114,6 +114,44 @@ class NamingWithNamespacedModelInSharedNamespaceTest < ActiveModel::TestCase end end +class NamingWithSuppliedModelNameTest < ActiveModel::TestCase + def setup + @model_name = ActiveModel::Name.new(Blog::Post, nil, 'Article') + end + + def test_singular + assert_equal 'article', @model_name.singular + end + + def test_plural + assert_equal 'articles', @model_name.plural + end + + def test_element + assert_equal 'article', @model_name.element + end + + def test_collection + assert_equal 'articles', @model_name.collection + end + + def test_partial_path + assert_equal 'articles/article', @model_name.partial_path + end + + def test_human + 'Article' + end + + def test_route_key + assert_equal 'articles', @model_name.route_key + end + + def test_param_key + assert_equal 'article', @model_name.param_key + end +end + class NamingHelpersTest < Test::Unit::TestCase def setup @klass = Contact @@ -171,4 +209,3 @@ class NamingHelpersTest < Test::Unit::TestCase ActiveModel::Naming.send(method, *args) end end - |