Skip to content

Commit

Permalink
to_sentence should return a duplicate
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Mongeau authored and wycats committed Aug 17, 2010
1 parent c017041 commit dd55830
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Expand Up @@ -26,7 +26,7 @@ def to_sentence(options = {})
when 0
""
when 1
self[0].to_s
self[0].to_s.dup
when 2
"#{self[0]}#{options[:two_words_connector]}#{self[1]}"
else
Expand Down
5 changes: 5 additions & 0 deletions activesupport/test/core_ext/array_ext_test.rb
Expand Up @@ -82,6 +82,11 @@ def test_one_element
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
Expand Down

0 comments on commit dd55830

Please sign in to comment.