Ticket #10390: fix_to_sentence_for_1_element.diff
| File fix_to_sentence_for_1_element.diff, 1.1 kB (added by chuyeow, 7 months ago) |
|---|
-
test/core_ext/array_ext_test.rb
old new 33 33 assert_equal "one", ['one'].to_sentence 34 34 assert_equal "one and two", ['one', 'two'].to_sentence 35 35 assert_equal "one, two, and three", ['one', 'two', 'three'].to_sentence 36 37 36 end 38 37 39 38 def test_to_sentence_with_connector … … 57 56 assert_equal "one", ['one'].to_sentence 58 57 end 59 58 59 def test_one_non_string_element 60 assert_equal '1', [1].to_sentence 61 end 60 62 end 61 63 62 64 class ArrayExtToSTests < Test::Unit::TestCase -
lib/active_support/core_ext/array/conversions.rb
old new 16 16 when 0 17 17 "" 18 18 when 1 19 self[0] 19 self[0].to_s 20 20 when 2 21 21 "#{self[0]} #{options[:connector]}#{self[1]}" 22 22 else