aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/activerecord/controller_runtime_test.rb
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2010-01-17 03:20:30 +0530
committerPratik Naik <pratiknaik@gmail.com>2010-01-17 03:20:30 +0530
commitb04230e3bbf912d60601e9e7b797c4cd43581d51 (patch)
tree97a2f784a2ec2bfae4f960af56a9280dad6f7774 /actionpack/test/activerecord/controller_runtime_test.rb
parent867829b187969607aa12f2b0457f25da9c204db0 (diff)
parent6e3bee6cf1f0d2684152292db0a8b757249824fd (diff)
downloadrails-b04230e3bbf912d60601e9e7b797c4cd43581d51.tar.gz
rails-b04230e3bbf912d60601e9e7b797c4cd43581d51.tar.bz2
rails-b04230e3bbf912d60601e9e7b797c4cd43581d51.zip
Merge remote branch 'mainstream/master'
Conflicts: actionpack/lib/action_controller/metal/flash.rb
Diffstat (limited to 'actionpack/test/activerecord/controller_runtime_test.rb')
-rw-r--r--actionpack/test/activerecord/controller_runtime_test.rb50
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