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

Changeset 8319

Show
Ignore:
Timestamp:
12/06/07 00:01:11 (9 months ago)
Author:
david
Message:

Fixed that the truncation of strings longer than 50 chars should use inspect so newlines etc are escaped (closes #10385) [norbert]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/CHANGELOG

    r8313 r8319  
    11*SVN* 
     2 
     3* Fixed that the truncation of strings longer than 50 chars should use inspect so newlines etc are escaped #10385 [norbert] 
    24 
    35* Fixed that habtm associations should be able to set :select as part of their definition and have that honored [DHH] 
  • trunk/activerecord/lib/active_record/base.rb

    r8298 r8319  
    20802080 
    20812081        if value.is_a?(String) && value.length > 50 
    2082           %("#{value[0..50]}...") 
     2082          "#{value[0..50]}...".inspect 
    20832083        elsif value.is_a?(Date) || value.is_a?(Time) 
    20842084          %("#{value.to_s(:db)}") 
  • trunk/activerecord/test/base_test.rb

    r8259 r8319  
    17331733  def test_attribute_for_inspect 
    17341734    t = topics(:first) 
    1735     t.content = %(This is some really long content, longer than 50 characters, so I can test that text is truncated correctly by the new ActiveRecord::Base#inspect method! Yay! BOOM!) 
     1735    t.title = "The First Topic Now Has A Title With\nNewlines And More Than 50 Characters" 
    17361736 
    17371737    assert_equal %("#{t.written_on.to_s(:db)}"), t.attribute_for_inspect(:written_on) 
    1738     assert_equal '"This is some really long content, longer than 50 ch..."', t.attribute_for_inspect(:content
     1738    assert_equal '"The First Topic Now Has A Title With\nNewlines And M..."', t.attribute_for_inspect(:title
    17391739  end 
    17401740