diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-21 13:53:21 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-21 13:53:47 -0700 |
commit | 96bd936b64ae06d4c38e8de862521e22d7c809b9 (patch) | |
tree | bb31dbdbe9a64c13ada149c1c28e3b8a696df5b5 /activerecord/test | |
parent | f4abe66d35662064c4b3634fc0691a27a4ee4253 (diff) | |
download | rails-96bd936b64ae06d4c38e8de862521e22d7c809b9.tar.gz rails-96bd936b64ae06d4c38e8de862521e22d7c809b9.tar.bz2 rails-96bd936b64ae06d4c38e8de862521e22d7c809b9.zip |
providing arel with column information when possible [#5392 state:resolved]
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/associations/join_model_test.rb | 10 | ||||
-rw-r--r-- | activerecord/test/cases/helper.rb | 9 |
2 files changed, 19 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/join_model_test.rb b/activerecord/test/cases/associations/join_model_test.rb index b83966e91c..f131dc01f6 100644 --- a/activerecord/test/cases/associations/join_model_test.rb +++ b/activerecord/test/cases/associations/join_model_test.rb @@ -44,6 +44,16 @@ class AssociationsJoinModelTest < ActiveRecord::TestCase assert !authors(:mary).unique_categorized_posts.loaded? end + def test_column_caching + # pre-heat our cache + Post.arel_table.columns + Comment.columns + + Post.connection.column_calls = 0 + 2.times { Post.joins(:comments).to_a } + assert_equal 0, Post.connection.column_calls + end + def test_has_many_uniq_through_find assert_equal 1, authors(:mary).unique_categorized_posts.find(:all).size end diff --git a/activerecord/test/cases/helper.rb b/activerecord/test/cases/helper.rb index 561bb22785..19a8a97c1a 100644 --- a/activerecord/test/cases/helper.rb +++ b/activerecord/test/cases/helper.rb @@ -57,6 +57,15 @@ ActiveRecord::Base.connection.class.class_eval do alias_method_chain :execute, :query_record end +ActiveRecord::Base.connection.extend Module.new { + attr_accessor :column_calls + def columns(*args) + @column_calls += 1 + super + end +} +ActiveRecord::Base.connection.column_calls = 0 + unless ENV['FIXTURE_DEBUG'] module ActiveRecord::TestFixtures::ClassMethods def try_to_load_dependency_with_silence(*args) |