mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix: attribute_for_inspect truncate upto (51 => 50) characters.
This commit is contained in:
parent
f9fec4f46b
commit
a8bd220768
2 changed files with 3 additions and 3 deletions
|
@ -273,7 +273,7 @@ module ActiveRecord
|
|||
# person = Person.create!(name: 'David Heinemeier Hansson ' * 3)
|
||||
#
|
||||
# person.attribute_for_inspect(:name)
|
||||
# # => "\"David Heinemeier Hansson David Heinemeier Hansson D...\""
|
||||
# # => "\"David Heinemeier Hansson David Heinemeier Hansson ...\""
|
||||
#
|
||||
# person.attribute_for_inspect(:created_at)
|
||||
# # => "\"2012-10-22 00:15:07\""
|
||||
|
@ -281,7 +281,7 @@ module ActiveRecord
|
|||
value = read_attribute(attr_name)
|
||||
|
||||
if value.is_a?(String) && value.length > 50
|
||||
"#{value[0..50]}...".inspect
|
||||
"#{value[0..49]}...".inspect
|
||||
elsif value.is_a?(Date) || value.is_a?(Time)
|
||||
%("#{value.to_s(:db)}")
|
||||
else
|
||||
|
|
|
@ -32,7 +32,7 @@ class AttributeMethodsTest < ActiveRecord::TestCase
|
|||
t.title = "The First Topic Now Has A Title With\nNewlines And More Than 50 Characters"
|
||||
|
||||
assert_equal %("#{t.written_on.to_s(:db)}"), t.attribute_for_inspect(:written_on)
|
||||
assert_equal '"The First Topic Now Has A Title With\nNewlines And M..."', t.attribute_for_inspect(:title)
|
||||
assert_equal '"The First Topic Now Has A Title With\nNewlines And ..."', t.attribute_for_inspect(:title)
|
||||
end
|
||||
|
||||
def test_attribute_present
|
||||
|
|
Loading…
Reference in a new issue