aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-05-14 03:57:24 -0700
committerJosé Valim <jose.valim@gmail.com>2011-05-14 03:57:24 -0700
commitc4837f6ce3f9864c4b98c9051f99e1f0b428f9d6 (patch)
tree6e902ccc598cf02e2f28fcb4dab7145b01619357 /actionpack
parentd49113023676fbf0b6653730f5bde759990caede (diff)
parent6d961242848ffe0eac69f190fd02f44aaeef3e0a (diff)
downloadrails-c4837f6ce3f9864c4b98c9051f99e1f0b428f9d6.tar.gz
rails-c4837f6ce3f9864c4b98c9051f99e1f0b428f9d6.tar.bz2
rails-c4837f6ce3f9864c4b98c9051f99e1f0b428f9d6.zip
Merge pull request #554 from tomafro/reset-activerecord-runtime-before-each-request
ActiveRecord::LogSubscriber.runtime should be reset at the start of each request
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/test/activerecord/controller_runtime_test.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/actionpack/test/activerecord/controller_runtime_test.rb b/actionpack/test/activerecord/controller_runtime_test.rb
index 7931da3741..b87b9f9c47 100644
--- a/actionpack/test/activerecord/controller_runtime_test.rb
+++ b/actionpack/test/activerecord/controller_runtime_test.rb
@@ -11,6 +11,10 @@ class ControllerRuntimeLogSubscriberTest < ActionController::TestCase
def show
render :inline => "<%= Project.all %>"
end
+
+ def zero
+ render :inline => "Zero DB runtime"
+ end
end
include ActiveSupport::LogSubscriber::TestHelper
@@ -37,6 +41,15 @@ class ControllerRuntimeLogSubscriberTest < ActionController::TestCase
wait
assert_equal 2, @logger.logged(:info).size
- assert_match(/\(Views: [\d.]+ms | ActiveRecord: [\d.]+ms\)/, @logger.logged(:info)[1])
+ assert_match(/\(Views: [\d.]+ms \| ActiveRecord: [\d.]+ms\)/, @logger.logged(:info)[1])
+ end
+
+ def test_runtime_reset_before_requests
+ ActiveRecord::LogSubscriber.runtime += 12345
+ get :zero
+ wait
+
+ assert_equal 2, @logger.logged(:info).size
+ assert_match(/\(Views: [\d.]+ms \| ActiveRecord: 0.0ms\)/, @logger.logged(:info)[1])
end
end