1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionpack/test/activerecord/controller_runtime_test.rb

42 lines
1.1 KiB
Ruby
Raw Normal View History

require 'active_record_unit'
2009-12-31 01:14:57 -05:00
require 'active_record/railties/controller_runtime'
require 'fixtures/project'
require 'rails/subscriber/test_helper'
require 'action_controller/railties/subscriber'
2009-12-31 01:14:57 -05:00
ActionController::Base.send :include, ActiveRecord::Railties::ControllerRuntime
2010-01-21 07:05:30 -05:00
class ControllerRuntimeSubscriberTest < ActionController::TestCase
class SubscriberController < ActionController::Base
def show
render :inline => "<%= Project.all %>"
end
end
2010-01-21 07:05:30 -05:00
include Rails::Subscriber::TestHelper
tests SubscriberController
def setup
@old_logger = ActionController::Base.logger
Rails::Subscriber.add(:action_controller, ActionController::Railties::Subscriber.new)
super
end
def teardown
super
Rails::Subscriber.subscribers.clear
ActionController::Base.logger = @old_logger
end
def set_logger(logger)
ActionController::Base.logger = logger
end
def test_log_with_active_record
get :show
wait
2010-01-19 06:52:10 -05:00
assert_equal 2, @logger.logged(:info).size
assert_match /\(Views: [\d\.]+ms | ActiveRecord: [\d\.]+ms\)/, @logger.logged(:info)[1]
end
end