aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/string_ext_test.rb
diff options
context:
space:
mode:
authorKuldeep Aggarwal <kd.engineer@yahoo.co.in>2014-04-19 01:31:07 +0530
committerKuldeep Aggarwal <kd.engineer@yahoo.co.in>2014-04-19 01:31:07 +0530
commit459f7bf38aa196cf4d2d970173b02d88e4a4e75c (patch)
tree1253ffbbacd1ac63b2d65b95f69113159db88e1c /activesupport/test/core_ext/string_ext_test.rb
parent5f72fc6af8ad19df2b4e4f442b9ab17dd6846f46 (diff)
downloadrails-459f7bf38aa196cf4d2d970173b02d88e4a4e75c.tar.gz
rails-459f7bf38aa196cf4d2d970173b02d88e4a4e75c.tar.bz2
rails-459f7bf38aa196cf4d2d970173b02d88e4a4e75c.zip
Fix inconsistent behavior from String#pluralize
Before: When calling String#pluralize with count=1 then it returned same string, but with count other than 1, returned new string. After: String#pluralize always return a new string. => Prevent mutation of a string inadvertently.
Diffstat (limited to 'activesupport/test/core_ext/string_ext_test.rb')
-rw-r--r--activesupport/test/core_ext/string_ext_test.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb
index f8d4d0f0dc..95df173880 100644
--- a/activesupport/test/core_ext/string_ext_test.rb
+++ b/activesupport/test/core_ext/string_ext_test.rb
@@ -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)