aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/relations_test.rb
diff options
context:
space:
mode:
authorDamien Mathieu <42@dmathieu.com>2012-07-06 16:53:33 +0200
committerDamien Mathieu <42@dmathieu.com>2012-07-06 20:04:38 +0200
commit7d0053e6a716be6345daa5e49dceda27ba8dfdb6 (patch)
treecdc268f748bf4426bb751dff41c18112193b06de /activerecord/test/cases/relations_test.rb
parent717aa92dd3f75dec04652940d5571ab34a2f79c3 (diff)
downloadrails-7d0053e6a716be6345daa5e49dceda27ba8dfdb6.tar.gz
rails-7d0053e6a716be6345daa5e49dceda27ba8dfdb6.tar.bz2
rails-7d0053e6a716be6345daa5e49dceda27ba8dfdb6.zip
Limit the number of records in Relation#inspect
While it's interesting to have the results array, it can make a console or a webpage freeze if there are a lot of them. So this limits the number of records displayed in #inspect to 10 and tells how much were effectively found.
Diffstat (limited to 'activerecord/test/cases/relations_test.rb')
-rw-r--r--activerecord/test/cases/relations_test.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb
index 7fdd42f150..bdf14e0a85 100644
--- a/activerecord/test/cases/relations_test.rb
+++ b/activerecord/test/cases/relations_test.rb
@@ -1316,4 +1316,9 @@ class RelationTest < ActiveRecord::TestCase
relation = Post.limit(2)
assert_equal "#<ActiveRecord::Relation [#{Post.limit(2).map(&:inspect).join(', ')}]>", relation.inspect
end
+
+ test "relations limits the records in #inspect at 10" do
+ relation = Post.limit(11)
+ assert_equal "#<ActiveRecord::Relation [#{Post.limit(10).map(&:inspect).join(', ')}, ...]>", relation.inspect
+ end
end