aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
diff options
context:
space:
mode:
authorlukeludwig <ludwig@tstmedia.com>2009-01-16 13:04:19 -0600
committerMichael Koziarski <michael@koziarski.com>2009-01-17 18:09:13 +1300
commit3ee4e009185173aab78f6503ee45e3ef4482874e (patch)
treecdf8f8219a3af0c6a33275d1217abfb4efc79d90 /activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
parentfe013ce93415a88b6c23fd750bd8cbab60d6395d (diff)
downloadrails-3ee4e009185173aab78f6503ee45e3ef4482874e.tar.gz
rails-3ee4e009185173aab78f6503ee45e3ef4482874e.tar.bz2
rails-3ee4e009185173aab78f6503ee45e3ef4482874e.zip
Cache columns for has_and_belongs_to_many associations
This avoids repeatedly calling SHOW COLUMNS when the association is queried [#1738 state:committed]
Diffstat (limited to 'activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb')
-rw-r--r--activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
index 2f08e09d43..ee03d5d944 100644
--- a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
@@ -775,4 +775,15 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase
end
end
end
+
+ def test_caching_of_columns
+ david = Developer.find(1)
+ # clear cache possibly created by other tests
+ david.projects.reset_column_information
+ assert_queries(1) { david.projects.columns; david.projects.columns }
+ # and again to verify that reset_column_information clears the cache correctly
+ david.projects.reset_column_information
+ assert_queries(1) { david.projects.columns; david.projects.columns }
+ end
+
end