runtime should be properly initialized.

This commit is contained in:
José Valim
2010-07-25 18:26:42 +02:00
parent 82c7ef837d
commit d02f2d2fb2
2 changed files with 5 additions and 2 deletions

View File

@@ -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

View File

@@ -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