1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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

Fix inconsistent behavior from String#pluralize
This commit is contained in:
Rafael Mendonça França 2014-04-22 12:13:26 -05:00
commit 148d909380
2 changed files with 6 additions and 1 deletions

View file

@ -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 file

@ -58,6 +58,11 @@ class StringInflectionsTest < ActiveSupport::TestCase
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)