Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #14801 from kuldeepaggarwal/fix-string-inflection

Fix inconsistent behavior from String#pluralize
  • Loading branch information...
commit 148d909380cf9b85a51875a6790a6d69a2d0d693 2 parents 85c2141 + 459f7bf
@rafaelfranca rafaelfranca authored
View
2  activesupport/lib/active_support/core_ext/string/inflections.rb
@@ -31,7 +31,7 @@ class String
def pluralize(count = nil, locale = :en)
locale = count if count.is_a?(Symbol)
if count == 1
- self
+ self.dup
else
ActiveSupport::Inflector.pluralize(self, locale)
end
View
5 activesupport/test/core_ext/string_ext_test.rb
@@ -58,6 +58,11 @@ def test_pluralize
assert_equal("blargles", "blargle".pluralize(2))
end
+ test 'pluralize with count = 1 still returns new string' do
+ name = "Kuldeep"
+ assert_not_same name.pluralize(1), name
+ end
+
def test_singularize
SingularToPlural.each do |singular, plural|
assert_equal(singular, plural.singularize)
Please sign in to comment.
Something went wrong with that request. Please try again.