Skip to content
This repository
Browse code

Fix that irregular plural inflections should not be double-pluralized…

…: 'people'.pluralize should return 'people' not 'peoples'.

[#1183 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information...
commit 82dd725fc195eb52eea9cbde9530ab9dff122e32 1 parent 84d24cd
Prem Sichanugrist authored July 04, 2008 jeremy committed August 09, 2009
3  activesupport/lib/active_support/inflector.rb
@@ -69,10 +69,13 @@ def irregular(singular, plural)
69 69
         @uncountables.delete(plural)
70 70
         if singular[0,1].upcase == plural[0,1].upcase
71 71
           plural(Regexp.new("(#{singular[0,1]})#{singular[1..-1]}$", "i"), '\1' + plural[1..-1])
  72
+          plural(Regexp.new("(#{plural[0,1]})#{plural[1..-1]}$", "i"), '\1' + plural[1..-1])
72 73
           singular(Regexp.new("(#{plural[0,1]})#{plural[1..-1]}$", "i"), '\1' + singular[1..-1])
73 74
         else
74 75
           plural(Regexp.new("#{singular[0,1].upcase}(?i)#{singular[1..-1]}$"), plural[0,1].upcase + plural[1..-1])
75 76
           plural(Regexp.new("#{singular[0,1].downcase}(?i)#{singular[1..-1]}$"), plural[0,1].downcase + plural[1..-1])
  77
+          plural(Regexp.new("#{plural[0,1].upcase}(?i)#{plural[1..-1]}$"), plural[0,1].upcase + plural[1..-1])
  78
+          plural(Regexp.new("#{plural[0,1].downcase}(?i)#{plural[1..-1]}$"), plural[0,1].downcase + plural[1..-1])
76 79
           singular(Regexp.new("#{plural[0,1].upcase}(?i)#{plural[1..-1]}$"), singular[0,1].upcase + singular[1..-1])
77 80
           singular(Regexp.new("#{plural[0,1].downcase}(?i)#{plural[1..-1]}$"), singular[0,1].downcase + singular[1..-1])
78 81
         end
10  activesupport/test/inflector_test.rb
@@ -256,6 +256,16 @@ def test_clear_with_default
256 256
     end
257 257
   end
258 258
 
  259
+  Irregularities.each do |irregularity|
  260
+    singular, plural = *irregularity
  261
+    ActiveSupport::Inflector.inflections do |inflect|
  262
+      define_method("test_pluralize_of_irregularity_#{plural}_should_be_the_same") do
  263
+        inflect.irregular(singular, plural)
  264
+        assert_equal plural, ActiveSupport::Inflector.pluralize(plural)
  265
+      end
  266
+    end
  267
+  end
  268
+
259 269
   [ :all, [] ].each do |scope|
260 270
     ActiveSupport::Inflector.inflections do |inflect|
261 271
       define_method("test_clear_inflections_with_#{scope.kind_of?(Array) ? "no_arguments" : scope}") do

0 notes on commit 82dd725

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