Fixed that pluralizing an empty string should return the same empty string, not "s" (closes #7720) [josh]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7569 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
59c36fd456
commit
3dcae9fefd
|
@ -1,5 +1,7 @@
|
||||||
*SVN*
|
*SVN*
|
||||||
|
|
||||||
|
* Fixed that pluralizing an empty string should return the same empty string, not "s" #7720 [josh]
|
||||||
|
|
||||||
* Added call to inspect on non-string classes for the logger #8533 [codahale]
|
* Added call to inspect on non-string classes for the logger #8533 [codahale]
|
||||||
|
|
||||||
* Deprecation: remove deprecated :mday option from Time, Date, and DateTime#change. [Jeremy Kemper]
|
* Deprecation: remove deprecated :mday option from Time, Date, and DateTime#change. [Jeremy Kemper]
|
||||||
|
|
|
@ -106,7 +106,7 @@ module Inflector
|
||||||
def pluralize(word)
|
def pluralize(word)
|
||||||
result = word.to_s.dup
|
result = word.to_s.dup
|
||||||
|
|
||||||
if inflections.uncountables.include?(result.downcase)
|
if word.empty? || inflections.uncountables.include?(result.downcase)
|
||||||
result
|
result
|
||||||
else
|
else
|
||||||
inflections.plurals.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }
|
inflections.plurals.each { |(rule, replacement)| break if result.gsub!(rule, replacement) }
|
||||||
|
|
|
@ -220,6 +220,10 @@ class InflectorTest < Test::Unit::TestCase
|
||||||
assert_equal "Plurals", Inflector.pluralize("Plurals")
|
assert_equal "Plurals", Inflector.pluralize("Plurals")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_pluralize_empty_string
|
||||||
|
assert_equal "", Inflector.pluralize("")
|
||||||
|
end
|
||||||
|
|
||||||
SingularToPlural.each do |singular, plural|
|
SingularToPlural.each do |singular, plural|
|
||||||
define_method "test_pluralize_#{singular}" do
|
define_method "test_pluralize_#{singular}" do
|
||||||
assert_equal(plural, Inflector.pluralize(singular))
|
assert_equal(plural, Inflector.pluralize(singular))
|
||||||
|
|
Loading…
Reference in New Issue