Skip to content

Commit

Permalink
Merge pull request #14801 from kuldeepaggarwal/fix-string-inflection
Browse files Browse the repository at this point in the history
Fix inconsistent behavior from String#pluralize
  • Loading branch information
rafaelfranca committed Apr 22, 2014
2 parents 85c2141 + 459f7bf commit 148d909
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions activesupport/test/core_ext/string_ext_test.rb
Expand Up @@ -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)
Expand Down

0 comments on commit 148d909

Please sign in to comment.