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:
commit
81fec5dfc4
2 changed files with 22 additions and 2 deletions
|
@ -71,8 +71,8 @@ module ActiveModel
|
||||||
# BookCover.model_name # => "BookCover"
|
# BookCover.model_name # => "BookCover"
|
||||||
# BookCover.model_name.human # => "Book cover"
|
# BookCover.model_name.human # => "Book cover"
|
||||||
#
|
#
|
||||||
# BookCover.model_name.i18n_key # => "book_cover"
|
# BookCover.model_name.i18n_key # => :book_cover
|
||||||
# BookModule::BookCover.model_name.i18n_key # => "book_module.book_cover"
|
# BookModule::BookCover.model_name.i18n_key # => :"book_module/book_cover"
|
||||||
#
|
#
|
||||||
# Providing the functionality that ActiveModel::Naming provides in your object
|
# Providing the functionality that ActiveModel::Naming provides in your object
|
||||||
# is required to pass the Active Model Lint test. So either extending the provided
|
# is required to pass the Active Model Lint test. So either extending the provided
|
||||||
|
|
|
@ -34,6 +34,10 @@ class NamingTest < ActiveModel::TestCase
|
||||||
def test_human
|
def test_human
|
||||||
assert_equal 'Track back', @model_name.human
|
assert_equal 'Track back', @model_name.human
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_i18n_key
|
||||||
|
assert_equal :"post/track_back", @model_name.i18n_key
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class NamingWithNamespacedModelInIsolatedNamespaceTest < ActiveModel::TestCase
|
class NamingWithNamespacedModelInIsolatedNamespaceTest < ActiveModel::TestCase
|
||||||
|
@ -74,6 +78,10 @@ class NamingWithNamespacedModelInIsolatedNamespaceTest < ActiveModel::TestCase
|
||||||
def test_param_key
|
def test_param_key
|
||||||
assert_equal 'post', @model_name.param_key
|
assert_equal 'post', @model_name.param_key
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_i18n_key
|
||||||
|
assert_equal :"blog/post", @model_name.i18n_key
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class NamingWithNamespacedModelInSharedNamespaceTest < ActiveModel::TestCase
|
class NamingWithNamespacedModelInSharedNamespaceTest < ActiveModel::TestCase
|
||||||
|
@ -114,6 +122,10 @@ class NamingWithNamespacedModelInSharedNamespaceTest < ActiveModel::TestCase
|
||||||
def test_param_key
|
def test_param_key
|
||||||
assert_equal 'blog_post', @model_name.param_key
|
assert_equal 'blog_post', @model_name.param_key
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_i18n_key
|
||||||
|
assert_equal :"blog/post", @model_name.i18n_key
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class NamingWithSuppliedModelNameTest < ActiveModel::TestCase
|
class NamingWithSuppliedModelNameTest < ActiveModel::TestCase
|
||||||
|
@ -154,6 +166,10 @@ class NamingWithSuppliedModelNameTest < ActiveModel::TestCase
|
||||||
def test_param_key
|
def test_param_key
|
||||||
assert_equal 'article', @model_name.param_key
|
assert_equal 'article', @model_name.param_key
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_i18n_key
|
||||||
|
assert_equal :"article", @model_name.i18n_key
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class NamingUsingRelativeModelNameTest < ActiveModel::TestCase
|
class NamingUsingRelativeModelNameTest < ActiveModel::TestCase
|
||||||
|
@ -188,6 +204,10 @@ class NamingUsingRelativeModelNameTest < ActiveModel::TestCase
|
||||||
def test_param_key
|
def test_param_key
|
||||||
assert_equal 'post', @model_name.param_key
|
assert_equal 'post', @model_name.param_key
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_i18n_key
|
||||||
|
assert_equal :"blog/post", @model_name.i18n_key
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class NamingHelpersTest < Test::Unit::TestCase
|
class NamingHelpersTest < Test::Unit::TestCase
|
||||||
|
|
Loading…
Reference in a new issue