diff options
author | José Valim <jose.valim@gmail.com> | 2011-05-23 03:11:15 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-05-23 03:11:15 -0700 |
commit | a8b2a895b795b02805a6d6478f7a8c55035e19d4 (patch) | |
tree | 04d4e9c245b58ecfdc1529dda21fd2bbcf17be12 /actionpack/test | |
parent | 6e5eedeb127f5bf9faf95460569931229a153cec (diff) | |
parent | 8a722e09122a2beeb122a8931a08b72c46d6bc50 (diff) | |
download | rails-a8b2a895b795b02805a6d6478f7a8c55035e19d4.tar.gz rails-a8b2a895b795b02805a6d6478f7a8c55035e19d4.tar.bz2 rails-a8b2a895b795b02805a6d6478f7a8c55035e19d4.zip |
Merge pull request #1228 from fcheung/db_time_fix2
Take into account time spent in AR even if a redirect occurs or if it is after the render
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/activerecord/controller_runtime_test.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/actionpack/test/activerecord/controller_runtime_test.rb b/actionpack/test/activerecord/controller_runtime_test.rb index b87b9f9c47..2d789395ce 100644 --- a/actionpack/test/activerecord/controller_runtime_test.rb +++ b/actionpack/test/activerecord/controller_runtime_test.rb @@ -15,6 +15,17 @@ class ControllerRuntimeLogSubscriberTest < ActionController::TestCase def zero render :inline => "Zero DB runtime" end + + def redirect + Project.all + redirect_to :action => 'show' + end + + def db_after_render + render :inline => "Hello world" + Project.all + ActiveRecord::LogSubscriber.runtime += 100 + end end include ActiveSupport::LogSubscriber::TestHelper @@ -52,4 +63,19 @@ class ControllerRuntimeLogSubscriberTest < ActionController::TestCase assert_equal 2, @logger.logged(:info).size assert_match(/\(Views: [\d.]+ms \| ActiveRecord: 0.0ms\)/, @logger.logged(:info)[1]) end + + def test_log_with_active_record_when_redirecting + get :redirect + wait + assert_equal 3, @logger.logged(:info).size + assert_match(/\(ActiveRecord: [\d.]+ms\)/, @logger.logged(:info)[2]) + end + + def test_include_time_query_time_after_rendering + get :db_after_render + wait + + assert_equal 2, @logger.logged(:info).size + assert_match(/\(Views: [\d.]+ms \| ActiveRecord: ([1-9][\d.]+)ms\)/, @logger.logged(:info)[1]) + end end |