diff options
author | Mikel Lindsaar <raasdnil@gmail.com> | 2010-01-17 12:46:51 +1100 |
---|---|---|
committer | Mikel Lindsaar <raasdnil@gmail.com> | 2010-01-17 12:46:51 +1100 |
commit | 6f663addaa7ed40f1133687d7a2be0958bf0c059 (patch) | |
tree | 7beb7f092c1979d1fd5ea6e7aaaf4f59c2f4abf4 /actionpack/test/activerecord/controller_runtime_test.rb | |
parent | 8834b2612b7ddda70ee6a685eb0063d3daa8e63d (diff) | |
parent | 3e94032227d450d479f511070c51f37f53d0ecc4 (diff) | |
download | rails-6f663addaa7ed40f1133687d7a2be0958bf0c059.tar.gz rails-6f663addaa7ed40f1133687d7a2be0958bf0c059.tar.bz2 rails-6f663addaa7ed40f1133687d7a2be0958bf0c059.zip |
Merge branch 'master' of github.com:lifo/docrails
Diffstat (limited to 'actionpack/test/activerecord/controller_runtime_test.rb')
-rw-r--r-- | actionpack/test/activerecord/controller_runtime_test.rb | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/actionpack/test/activerecord/controller_runtime_test.rb b/actionpack/test/activerecord/controller_runtime_test.rb index 0f534da14b..37c7738301 100644 --- a/actionpack/test/activerecord/controller_runtime_test.rb +++ b/actionpack/test/activerecord/controller_runtime_test.rb @@ -1,39 +1,53 @@ require 'active_record_unit' require 'active_record/railties/controller_runtime' require 'fixtures/project' +require 'rails/subscriber/test_helper' +require 'action_controller/railties/subscriber' ActionController::Base.send :include, ActiveRecord::Railties::ControllerRuntime -class ARLoggingController < ActionController::Base - def show - render :inline => "<%= Project.all %>" +module ControllerRuntimeSubscriberTest + class SubscriberController < ActionController::Base + def show + render :inline => "<%= Project.all %>" + end end -end -class ARLoggingTest < ActionController::TestCase - tests ARLoggingController + def self.included(base) + base.tests SubscriberController + end def setup + @old_logger = ActionController::Base.logger + Rails::Subscriber.add(:action_controller, ActionController::Railties::Subscriber.new) super - set_logger end - def wait - ActiveSupport::Notifications.notifier.wait + 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 - assert_match /ActiveRecord runtime/, logs[3] + + assert_equal 2, @logger.logged(:info).size + assert_match /\(Views: [\d\.]+ms | ActiveRecord: [\d\.]+ms\)/, @logger.logged(:info)[1] end - private - def set_logger - @controller.logger = MockLogger.new - end + class SyncSubscriberTest < ActionController::TestCase + include Rails::Subscriber::SyncTestHelper + include ControllerRuntimeSubscriberTest + end - def logs - @logs ||= @controller.logger.logged.compact.map {|l| l.to_s.strip} - end -end + class AsyncSubscriberTest < ActionController::TestCase + include Rails::Subscriber::AsyncTestHelper + include ControllerRuntimeSubscriberTest + end +end
\ No newline at end of file |