1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

to_sentence should return a duplicate

This commit is contained in:
Matthew Mongeau 2010-08-17 16:46:02 -04:00 committed by wycats
parent c017041e68
commit dd55830bb2
2 changed files with 6 additions and 1 deletions

View file

@ -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

View file

@ -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