diff options
author | José Valim <jose.valim@gmail.com> | 2010-07-25 18:26:42 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-07-25 18:26:42 +0200 |
commit | d02f2d2fb213584ce52a231063c948def856f657 (patch) | |
tree | a9c07676d888d14ab5f2298dfe676fbb0ab3eb26 /activerecord | |
parent | 82c7ef837d32897717b7c6e54cfa6f00d218a242 (diff) | |
download | rails-d02f2d2fb213584ce52a231063c948def856f657.tar.gz rails-d02f2d2fb213584ce52a231063c948def856f657.tar.bz2 rails-d02f2d2fb213584ce52a231063c948def856f657.zip |
runtime should be properly initialized.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/log_subscriber.rb | 3 | ||||
-rw-r--r-- | activerecord/test/cases/log_subscriber_test.rb | 4 |
2 files changed, 5 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/log_subscriber.rb b/activerecord/lib/active_record/log_subscriber.rb index 74b5893bfb..c7ae12977a 100644 --- a/activerecord/lib/active_record/log_subscriber.rb +++ b/activerecord/lib/active_record/log_subscriber.rb @@ -5,7 +5,7 @@ module ActiveRecord end def self.runtime - Thread.current["active_record_sql_runtime"] + Thread.current["active_record_sql_runtime"] ||= 0 end def self.reset_runtime @@ -45,5 +45,4 @@ module ActiveRecord end end -ActiveRecord::LogSubscriber.runtime = 0 ActiveRecord::LogSubscriber.attach_to :active_record
\ No newline at end of file diff --git a/activerecord/test/cases/log_subscriber_test.rb b/activerecord/test/cases/log_subscriber_test.rb index 342daa19df..cbaaca764b 100644 --- a/activerecord/test/cases/log_subscriber_test.rb +++ b/activerecord/test/cases/log_subscriber_test.rb @@ -57,4 +57,8 @@ class LogSubscriberTest < ActiveRecord::TestCase wait assert_equal 0, @logger.logged(:debug).size end + + def test_initializes_runtime + Thread.new { assert_equal 0, ActiveRecord::LogSubscriber.runtime }.join + end end |