diff options
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/text_helper.rb | 2 | ||||
-rw-r--r-- | actionpack/test/template/text_helper_test.rb | 4 |
3 files changed, 7 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 2ce09ede42..59e2577608 100644 --- a/actionpack/CHANGELOG +++ b/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] diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb index 36ed899cf0..91f368fa45 100644 --- a/actionpack/lib/action_view/helpers/text_helper.rb +++ b/actionpack/lib/action_view/helpers/text_helper.rb @@ -60,7 +60,7 @@ module ActionView # 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 diff --git a/actionpack/test/template/text_helper_test.rb b/actionpack/test/template/text_helper_test.rb index 6eda59affe..cf945365b4 100644 --- a/actionpack/test/template/text_helper_test.rb +++ b/actionpack/test/template/text_helper_test.rb @@ -112,6 +112,10 @@ class TextHelperTest < Test::Unit::TestCase 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 |