mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Fixed issue #6363, avoid to pluralized already pluralized names and singularize a single in generators, for example stadia is a valid plural for stadium. But calling pluralize for stadia will return stadias which sematically is not corrent in this case
[#6363 state:committed] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
This commit is contained in:
committed by
Santiago Pastorino
parent
1754bd9b20
commit
c6fac7b449
@@ -118,11 +118,11 @@ module Rails
|
||||
end
|
||||
|
||||
def singular_table_name
|
||||
@singular_table_name ||= table_name.singularize
|
||||
@singular_table_name ||= (pluralize_table_names? ? table_name.singularize : table_name)
|
||||
end
|
||||
|
||||
def plural_table_name
|
||||
@plural_table_name ||= table_name.pluralize
|
||||
@plural_table_name ||= (pluralize_table_names? ? table_name : table_name.pluralize)
|
||||
end
|
||||
|
||||
def plural_file_name
|
||||
|
||||
@@ -98,6 +98,11 @@ class NamedBaseTest < Rails::Generators::TestCase
|
||||
assert_name g, 'posts', :index_helper
|
||||
end
|
||||
|
||||
def test_index_helper_to_pluralize_once
|
||||
g = generator ['Stadium']
|
||||
assert_name g, 'stadia', :index_helper
|
||||
end
|
||||
|
||||
def test_index_helper_with_uncountable
|
||||
g = generator ['Sheep']
|
||||
assert_name g, 'sheep_index', :index_helper
|
||||
|
||||
Reference in New Issue
Block a user