diff options
author | Matthew Mongeau <matt@toastyapps.com> | 2010-08-17 16:46:02 -0400 |
---|---|---|
committer | wycats <wycats@gmail.com> | 2010-08-17 13:52:37 -0700 |
commit | dd55830bb279a4ef492727d6ffda169eb569ba27 (patch) | |
tree | 1b127920f6563fd5445bd48fb91d1bf32dbdd0c8 /activesupport | |
parent | c017041e68c3b7ca4677db0ab420cb7d8bccb72f (diff) | |
download | rails-dd55830bb279a4ef492727d6ffda169eb569ba27.tar.gz rails-dd55830bb279a4ef492727d6ffda169eb569ba27.tar.bz2 rails-dd55830bb279a4ef492727d6ffda169eb569ba27.zip |
to_sentence should return a duplicate
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/core_ext/array/conversions.rb | 2 | ||||
-rw-r--r-- | activesupport/test/core_ext/array_ext_test.rb | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/array/conversions.rb b/activesupport/lib/active_support/core_ext/array/conversions.rb index 7585137aca..baefa9cae4 100644 --- a/activesupport/lib/active_support/core_ext/array/conversions.rb +++ b/activesupport/lib/active_support/core_ext/array/conversions.rb @@ -26,7 +26,7 @@ class Array when 0 "" when 1 - self[0].to_s + self[0].to_s.dup when 2 "#{self[0]}#{options[:two_words_connector]}#{self[1]}" else diff --git a/activesupport/test/core_ext/array_ext_test.rb b/activesupport/test/core_ext/array_ext_test.rb index d14ae39737..d7ab3ce605 100644 --- a/activesupport/test/core_ext/array_ext_test.rb +++ b/activesupport/test/core_ext/array_ext_test.rb @@ -82,6 +82,11 @@ class ArrayExtToSentenceTests < Test::Unit::TestCase assert_equal "one", ['one'].to_sentence end + def test_one_element_not_same_object + elements = ["one"] + assert_not_equal elements[0].object_id, elements.to_sentence.object_id + end + def test_one_non_string_element assert_equal '1', [1].to_sentence end |