diff options
author | Xavier Noria <fxn@hashref.com> | 2012-01-26 02:50:46 -0800 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2012-01-26 02:50:46 -0800 |
commit | f251437415f7b803f7a84118fcc970a111ace266 (patch) | |
tree | c4a86b401027742fe78ab6087af8ed91eb53c280 /activerecord/test | |
parent | d11347df7203cb5c82caad5c9949830980e3eb6a (diff) | |
download | rails-f251437415f7b803f7a84118fcc970a111ace266.tar.gz rails-f251437415f7b803f7a84118fcc970a111ace266.tar.bz2 rails-f251437415f7b803f7a84118fcc970a111ace266.zip |
disable automatic explain if there is no logger [closes #4671]
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/explain_test.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/activerecord/test/cases/explain_test.rb b/activerecord/test/cases/explain_test.rb index 6ae6f83446..83c9b6e107 100644 --- a/activerecord/test/cases/explain_test.rb +++ b/activerecord/test/cases/explain_test.rb @@ -14,7 +14,7 @@ if ActiveRecord::Base.connection.supports_explain? base.connection end - def test_logging_query_plan + def test_logging_query_plan_with_logger base.logger.expects(:warn).with do |message| message.starts_with?('EXPLAIN for:') end @@ -24,6 +24,20 @@ if ActiveRecord::Base.connection.supports_explain? end end + def test_logging_query_plan_without_logger + original = base.logger + base.logger = nil + + base.logger.expects(:warn).never + + with_threshold(0) do + car = Car.where(:name => 'honda').first + assert_equal 'honda', car.name + end + ensure + base.logger = original + end + def test_collect_queries_for_explain base.auto_explain_threshold_in_seconds = nil queries = Thread.current[:available_queries_for_explain] = [] |