mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Revert "Take into account time spent in AR even if a redirect occurs or if it is after the render" because it's causing test failures about missing db_during_render.
This reverts commit 60b55baca9
.
This commit is contained in:
parent
7124659f3e
commit
ba3ea9c90b
2 changed files with 3 additions and 31 deletions
|
@ -15,17 +15,6 @@ 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
|
||||
|
@ -63,19 +52,4 @@ 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
|
||||
|
|
|
@ -23,8 +23,8 @@ module ActiveRecord
|
|||
db_rt_before_render = ActiveRecord::LogSubscriber.reset_runtime
|
||||
runtime = super
|
||||
db_rt_after_render = ActiveRecord::LogSubscriber.reset_runtime
|
||||
self.db_runtime = db_rt_before_render + db_during_render
|
||||
runtime - db_during_render
|
||||
self.db_runtime = db_rt_before_render + db_rt_after_render
|
||||
runtime - db_rt_after_render
|
||||
else
|
||||
super
|
||||
end
|
||||
|
@ -32,9 +32,7 @@ module ActiveRecord
|
|||
|
||||
def append_info_to_payload(payload)
|
||||
super
|
||||
if ActiveRecord::Base.connected?
|
||||
payload[:db_runtime] = (db_runtime || 0) + ActiveRecord::LogSubscriber.reset_runtime
|
||||
end
|
||||
payload[:db_runtime] = db_runtime
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
|
|
Loading…
Reference in a new issue