1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #3872 from marcandre/i18n_key

ActiveModel::Name#i18n_key: Fix doc and add tests
This commit is contained in:
José Valim 2011-12-06 00:41:43 -08:00
commit 81fec5dfc4
2 changed files with 22 additions and 2 deletions

View file

@ -71,8 +71,8 @@ module ActiveModel
# BookCover.model_name # => "BookCover"
# BookCover.model_name.human # => "Book cover"
#
# BookCover.model_name.i18n_key # => "book_cover"
# BookModule::BookCover.model_name.i18n_key # => "book_module.book_cover"
# BookCover.model_name.i18n_key # => :book_cover
# BookModule::BookCover.model_name.i18n_key # => :"book_module/book_cover"
#
# Providing the functionality that ActiveModel::Naming provides in your object
# is required to pass the Active Model Lint test. So either extending the provided

View file

@ -34,6 +34,10 @@ class NamingTest < ActiveModel::TestCase
def test_human
assert_equal 'Track back', @model_name.human
end
def test_i18n_key
assert_equal :"post/track_back", @model_name.i18n_key
end
end
class NamingWithNamespacedModelInIsolatedNamespaceTest < ActiveModel::TestCase
@ -74,6 +78,10 @@ class NamingWithNamespacedModelInIsolatedNamespaceTest < ActiveModel::TestCase
def test_param_key
assert_equal 'post', @model_name.param_key
end
def test_i18n_key
assert_equal :"blog/post", @model_name.i18n_key
end
end
class NamingWithNamespacedModelInSharedNamespaceTest < ActiveModel::TestCase
@ -114,6 +122,10 @@ class NamingWithNamespacedModelInSharedNamespaceTest < ActiveModel::TestCase
def test_param_key
assert_equal 'blog_post', @model_name.param_key
end
def test_i18n_key
assert_equal :"blog/post", @model_name.i18n_key
end
end
class NamingWithSuppliedModelNameTest < ActiveModel::TestCase
@ -154,6 +166,10 @@ class NamingWithSuppliedModelNameTest < ActiveModel::TestCase
def test_param_key
assert_equal 'article', @model_name.param_key
end
def test_i18n_key
assert_equal :"article", @model_name.i18n_key
end
end
class NamingUsingRelativeModelNameTest < ActiveModel::TestCase
@ -188,6 +204,10 @@ class NamingUsingRelativeModelNameTest < ActiveModel::TestCase
def test_param_key
assert_equal 'post', @model_name.param_key
end
def test_i18n_key
assert_equal :"blog/post", @model_name.i18n_key
end
end
class NamingHelpersTest < Test::Unit::TestCase