Skip to content
This repository
Browse code

fix inflector bug where -ice gets pluralized into -ouse

This should happen for mouse or louse, but not slice or pumice.
  • Loading branch information...
commit 16e7f2f809c586d2d9a27c2b57395350b596e0b7 1 parent cbe74cf
Wes Morgan authored February 25, 2012
8  activesupport/lib/active_support/inflections.rb
@@ -16,8 +16,8 @@ module ActiveSupport
16 16
     inflect.plural(/([^aeiouy]|qu)y$/i, '\1ies')
17 17
     inflect.plural(/(x|ch|ss|sh)$/i, '\1es')
18 18
     inflect.plural(/(matr|vert|ind)(?:ix|ex)$/i, '\1ices')
19  
-    inflect.plural(/(m|l)ouse$/i, '\1ice')
20  
-    inflect.plural(/(m|l)ice$/i, '\1ice')
  19
+    inflect.plural(/^(m|l)ouse$/i, '\1ice')
  20
+    inflect.plural(/^(m|l)ice$/i, '\1ice')
21 21
     inflect.plural(/^(ox)$/i, '\1en')
22 22
     inflect.plural(/^(oxen)$/i, '\1')
23 23
     inflect.plural(/(quiz)$/i, '\1zes')
@@ -36,7 +36,7 @@ module ActiveSupport
36 36
     inflect.singular(/(s)eries$/i, '\1eries')
37 37
     inflect.singular(/(m)ovies$/i, '\1ovie')
38 38
     inflect.singular(/(x|ch|ss|sh)es$/i, '\1')
39  
-    inflect.singular(/(m|l)ice$/i, '\1ouse')
  39
+    inflect.singular(/^(m|l)ice$/i, '\1ouse')
40 40
     inflect.singular(/(bus)(es)?$/i, '\1')
41 41
     inflect.singular(/(o)es$/i, '\1')
42 42
     inflect.singular(/(shoe)s$/i, '\1')
@@ -58,6 +58,6 @@ module ActiveSupport
58 58
     inflect.irregular('cow', 'kine')
59 59
     inflect.irregular('zombie', 'zombies')
60 60
 
61  
-    inflect.uncountable(%w(equipment information rice money species series fish sheep jeans))
  61
+    inflect.uncountable(%w(equipment information rice money species series fish sheep jeans police))
62 62
   end
63 63
 end
4  activesupport/test/inflector_test_cases.rb
@@ -109,7 +109,9 @@ module InflectorTestCases
109 109
 
110 110
     # regression tests against improper inflection regexes
111 111
     "|ice"        => "|ices",
112  
-    "|ouse"       => "|ouses"
  112
+    "|ouse"       => "|ouses",
  113
+    "slice"       => "slices",
  114
+    "police"      => "police"
113 115
   }
114 116
 
115 117
   CamelToUnderscore = {

0 notes on commit 16e7f2f

Please sign in to comment.
Something went wrong with that request. Please try again.