mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Make sure Array#to_sentence always returns a String
This commit is contained in:
parent
4a0f314d8a
commit
a64f3e4195
2 changed files with 7 additions and 1 deletions
|
@ -74,7 +74,7 @@ class Array
|
|||
when 0
|
||||
''
|
||||
when 1
|
||||
self[0].to_s.dup
|
||||
"#{self[0]}"
|
||||
when 2
|
||||
"#{self[0]}#{options[:two_words_connector]}#{self[1]}"
|
||||
else
|
||||
|
|
|
@ -60,6 +60,12 @@ class ToSentenceTest < ActiveSupport::TestCase
|
|||
|
||||
assert_equal exception.message, "Unknown key: :passing. Valid keys are: :words_connector, :two_words_connector, :last_word_connector, :locale"
|
||||
end
|
||||
|
||||
def test_always_returns_string
|
||||
assert_instance_of String, [ActiveSupport::SafeBuffer.new('one')].to_sentence
|
||||
assert_instance_of String, [ActiveSupport::SafeBuffer.new('one'), 'two'].to_sentence
|
||||
assert_instance_of String, [ActiveSupport::SafeBuffer.new('one'), 'two', 'three'].to_sentence
|
||||
end
|
||||
end
|
||||
|
||||
class ToSTest < ActiveSupport::TestCase
|
||||
|
|
Loading…
Reference in a new issue