diff options
author | namusyaka <namusyaka@gmail.com> | 2013-07-09 20:01:48 +0900 |
---|---|---|
committer | namusyaka <namusyaka@gmail.com> | 2013-07-09 20:01:48 +0900 |
commit | a8bd220768625637ef240049a71d82a60041755f (patch) | |
tree | 0bf051069aa85c65bc3b17a1b5072e8d7510f838 | |
parent | f9fec4f46ba04f7c9a2d32941a1e386664b0145f (diff) | |
download | rails-a8bd220768625637ef240049a71d82a60041755f.tar.gz rails-a8bd220768625637ef240049a71d82a60041755f.tar.bz2 rails-a8bd220768625637ef240049a71d82a60041755f.zip |
Fix: attribute_for_inspect truncate upto (51 => 50) characters.
-rw-r--r-- | activerecord/lib/active_record/attribute_methods.rb | 4 | ||||
-rw-r--r-- | activerecord/test/cases/attribute_methods_test.rb | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb index c07fd67216..b3f97522c2 100644 --- a/activerecord/lib/active_record/attribute_methods.rb +++ b/activerecord/lib/active_record/attribute_methods.rb @@ -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 diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb index ee0150558d..170c4cd9cd 100644 --- a/activerecord/test/cases/attribute_methods_test.rb +++ b/activerecord/test/cases/attribute_methods_test.rb @@ -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 |