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:
parent
c017041e68
commit
dd55830bb2
2 changed files with 6 additions and 1 deletions
|
@ -26,7 +26,7 @@ class Array
|
||||||
when 0
|
when 0
|
||||||
""
|
""
|
||||||
when 1
|
when 1
|
||||||
self[0].to_s
|
self[0].to_s.dup
|
||||||
when 2
|
when 2
|
||||||
"#{self[0]}#{options[:two_words_connector]}#{self[1]}"
|
"#{self[0]}#{options[:two_words_connector]}#{self[1]}"
|
||||||
else
|
else
|
||||||
|
|
|
@ -82,6 +82,11 @@ class ArrayExtToSentenceTests < Test::Unit::TestCase
|
||||||
assert_equal "one", ['one'].to_sentence
|
assert_equal "one", ['one'].to_sentence
|
||||||
end
|
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
|
def test_one_non_string_element
|
||||||
assert_equal '1', [1].to_sentence
|
assert_equal '1', [1].to_sentence
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue