diff options
author | José Valim <jose.valim@gmail.com> | 2012-04-30 00:13:40 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2012-04-30 00:13:40 -0700 |
commit | 66c5ac3be9c362cd7cadb57cc60cfc48eade39db (patch) | |
tree | 67870229e2cf77faf6c9f5fa3f938a40d8b9e1fc | |
parent | 976b1709bab2150d28cdf65093cda8f2e40865fb (diff) | |
parent | 16e7f2f809c586d2d9a27c2b57395350b596e0b7 (diff) | |
download | rails-66c5ac3be9c362cd7cadb57cc60cfc48eade39db.tar.gz rails-66c5ac3be9c362cd7cadb57cc60cfc48eade39db.tar.bz2 rails-66c5ac3be9c362cd7cadb57cc60cfc48eade39db.zip |
Merge pull request #5177 from cap10morgan/fix-gh-issue-4374
fix inflector bug where -ice gets singularized into -ouse
-rw-r--r-- | activesupport/lib/active_support/inflections.rb | 8 | ||||
-rw-r--r-- | activesupport/test/inflector_test_cases.rb | 4 |
2 files changed, 7 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/inflections.rb b/activesupport/lib/active_support/inflections.rb index b3eb1333ca..7eb61cd1a0 100644 --- a/activesupport/lib/active_support/inflections.rb +++ b/activesupport/lib/active_support/inflections.rb @@ -16,8 +16,8 @@ module ActiveSupport inflect.plural(/([^aeiouy]|qu)y$/i, '\1ies') inflect.plural(/(x|ch|ss|sh)$/i, '\1es') inflect.plural(/(matr|vert|ind)(?:ix|ex)$/i, '\1ices') - inflect.plural(/(m|l)ouse$/i, '\1ice') - inflect.plural(/(m|l)ice$/i, '\1ice') + inflect.plural(/^(m|l)ouse$/i, '\1ice') + inflect.plural(/^(m|l)ice$/i, '\1ice') inflect.plural(/^(ox)$/i, '\1en') inflect.plural(/^(oxen)$/i, '\1') inflect.plural(/(quiz)$/i, '\1zes') @@ -36,7 +36,7 @@ module ActiveSupport inflect.singular(/(s)eries$/i, '\1eries') inflect.singular(/(m)ovies$/i, '\1ovie') inflect.singular(/(x|ch|ss|sh)es$/i, '\1') - inflect.singular(/(m|l)ice$/i, '\1ouse') + inflect.singular(/^(m|l)ice$/i, '\1ouse') inflect.singular(/(bus)(es)?$/i, '\1') inflect.singular(/(o)es$/i, '\1') inflect.singular(/(shoe)s$/i, '\1') @@ -58,6 +58,6 @@ module ActiveSupport inflect.irregular('cow', 'kine') inflect.irregular('zombie', 'zombies') - inflect.uncountable(%w(equipment information rice money species series fish sheep jeans)) + inflect.uncountable(%w(equipment information rice money species series fish sheep jeans police)) end end diff --git a/activesupport/test/inflector_test_cases.rb b/activesupport/test/inflector_test_cases.rb index 86c5e1f135..4d10cfca25 100644 --- a/activesupport/test/inflector_test_cases.rb +++ b/activesupport/test/inflector_test_cases.rb @@ -109,7 +109,9 @@ module InflectorTestCases # regression tests against improper inflection regexes "|ice" => "|ices", - "|ouse" => "|ouses" + "|ouse" => "|ouses", + "slice" => "slices", + "police" => "police" } CamelToUnderscore = { |