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:
commit
148d909380
2 changed files with 6 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue