提交 ef57b93a 编写于 作者: J Jeremy Kemper

to_sentence returns self[0].to_s instead of just self[0] for arrays of length...

to_sentence returns self[0].to_s instead of just self[0] for arrays of length 1. Closes #10390 [Chu Yeow, mrj]


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8340 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 77de690a
......@@ -16,7 +16,7 @@ def to_sentence(options = {})
when 0
""
when 1
self[0]
self[0].to_s
when 2
"#{self[0]} #{options[:connector]}#{self[1]}"
else
......
......@@ -33,7 +33,6 @@ def test_plain_array_to_sentence
assert_equal "one", ['one'].to_sentence
assert_equal "one and two", ['one', 'two'].to_sentence
assert_equal "one, two, and three", ['one', 'two', 'three'].to_sentence
end
def test_to_sentence_with_connector
......@@ -57,6 +56,9 @@ def test_one_element
assert_equal "one", ['one'].to_sentence
end
def test_one_non_string_element
assert_equal '1', [1].to_sentence
end
end
class ArrayExtToSTests < Test::Unit::TestCase
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册