class ControllerRuntimeLogSubscriberTest

Public Instance Methods

set_logger(logger) click to toggle source
# File actionview/test/activerecord/controller_runtime_test.rb, line 54
def set_logger(logger)
  ActionController::Base.logger = logger
end
setup() click to toggle source
Calls superclass method
# File actionview/test/activerecord/controller_runtime_test.rb, line 42
def setup
  @old_logger = ActionController::Base.logger
  super
  ActionController::LogSubscriber.attach_to :action_controller
end
teardown() click to toggle source
Calls superclass method
# File actionview/test/activerecord/controller_runtime_test.rb, line 48
def teardown
  super
  ActiveSupport::LogSubscriber.log_subscribers.clear
  ActionController::Base.logger = @old_logger
end
test_include_time_query_time_after_rendering() click to toggle source
# File actionview/test/activerecord/controller_runtime_test.rb, line 88
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
test_log_with_active_record() click to toggle source
# File actionview/test/activerecord/controller_runtime_test.rb, line 58
def test_log_with_active_record
  get :show
  wait

  assert_equal 2, @logger.logged(:info).size
  assert_match(/\(Views: [\d.]+ms \| ActiveRecord: [\d.]+ms\)/, @logger.logged(:info)[1])
end
test_log_with_active_record_when_post() click to toggle source
# File actionview/test/activerecord/controller_runtime_test.rb, line 75
def test_log_with_active_record_when_post
  post :create
  wait
  assert_match(/ActiveRecord: ([1-9][\d.]+)ms\)/, @logger.logged(:info)[2])
end
test_log_with_active_record_when_redirecting() click to toggle source
# File actionview/test/activerecord/controller_runtime_test.rb, line 81
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
test_runtime_reset_before_requests() click to toggle source
# File actionview/test/activerecord/controller_runtime_test.rb, line 66
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