aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorMehmet Emin İNAÇ <mehmetemininac@gmail.com>2015-08-02 04:38:36 +0300
committerMehmet Emin İNAÇ <mehmetemininac@gmail.com>2015-08-03 06:40:14 +0300
commitf744d627364a9a98dedda5b30711bf80ebc3451f (patch)
treea4522ab8b60e8392eddf443d09c42bd91e8504e4 /activerecord/test
parent722abe1722a8bcf1798fc7f7f9a8cf4dcfa28e88 (diff)
downloadrails-f744d627364a9a98dedda5b30711bf80ebc3451f.tar.gz
rails-f744d627364a9a98dedda5b30711bf80ebc3451f.tar.bz2
rails-f744d627364a9a98dedda5b30711bf80ebc3451f.zip
Use memoization for collection associations ids reader
Fixes #21082 remove extra space
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb
index 21e2ee3b11..2cbee3cd21 100644
--- a/activerecord/test/cases/associations/has_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_associations_test.rb
@@ -2308,4 +2308,12 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
assert_instance_of PostWithErrorDestroying, error.record
end
+
+ def test_ids_reader_memoization
+ car = Car.create!(name: 'Tofaş')
+ bulb = Bulb.create!(car: car)
+
+ assert_equal [bulb.id], car.bulb_ids
+ assert_no_queries { car.bulb_ids }
+ end
end