Skip to content

Commit

Permalink
Fixed TextHelper#pluralize to handle 1 as a string (closes #5905) [ra…
Browse files Browse the repository at this point in the history
…ils@bencurtis.com]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4993 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
dhh committed Sep 4, 2006
1 parent d52cee3 commit a693b3b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*

* Fixed TextHelper#pluralize to handle 1 as a string #5905 [rails@bencurtis.com]

* Improved resolution of DateHelper#distance_of_time_in_words for better precision #5994 [Bob Silva]

* Changed that uncaught exceptions raised any where in the application will cause RAILS_ROOT/public/500.html to be read and shown instead of just the static "Application error (Rails)" [DHH]
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/helpers/text_helper.rb
Expand Up @@ -60,7 +60,7 @@ def excerpt(text, phrase, radius = 100, excerpt_string = "...")

# Attempts to pluralize the +singular+ word unless +count+ is 1. See source for pluralization rules.
def pluralize(count, singular, plural = nil)
"#{count} " + if count == 1
"#{count} " + if count == 1 || count == '1'
singular
elsif plural
plural
Expand Down
4 changes: 4 additions & 0 deletions actionpack/test/template/text_helper_test.rb
Expand Up @@ -112,6 +112,10 @@ def test_word_wrap
def test_pluralization
assert_equal("1 count", pluralize(1, "count"))
assert_equal("2 counts", pluralize(2, "count"))
assert_equal("1 count", pluralize('1', "count"))
assert_equal("2 counts", pluralize('2', "count"))
assert_equal("1,066 counts", pluralize('1,066', "count"))
assert_equal("1.25 counts", pluralize('1.25', "count"))
end

def test_auto_link_parsing
Expand Down

0 comments on commit a693b3b

Please sign in to comment.