Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

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  
    3333    assert_equal "one", ['one'].to_sentence 
    3434    assert_equal "one and two", ['one', 'two'].to_sentence 
    3535    assert_equal "one, two, and three", ['one', 'two', 'three'].to_sentence 
    36  
    3736  end 
    3837 
    3938  def test_to_sentence_with_connector 
     
    5756    assert_equal "one", ['one'].to_sentence 
    5857  end 
    5958 
     59  def test_one_non_string_element 
     60    assert_equal '1', [1].to_sentence 
     61  end 
    6062end 
    6163 
    6264class ArrayExtToSTests < Test::Unit::TestCase 
  • lib/active_support/core_ext/array/conversions.rb

    old new  
    1616            when 0 
    1717              "" 
    1818            when 1 
    19               self[0] 
     19              self[0].to_s 
    2020            when 2 
    2121              "#{self[0]} #{options[:connector]}#{self[1]}" 
    2222            else