diff options
author | José Valim <jose.valim@gmail.com> | 2010-01-13 01:18:23 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-01-13 01:19:24 +0100 |
commit | 01839834fd19e7be1e89309416bed497ac5ea0a0 (patch) | |
tree | 7e7f0584058845b2b4d92942643e8fbffada93d5 /actionpack/test/activerecord | |
parent | b0d35ad00c3d7f6f63aa7ae8f3d3cb802bb90d69 (diff) | |
download | rails-01839834fd19e7be1e89309416bed497ac5ea0a0.tar.gz rails-01839834fd19e7be1e89309416bed497ac5ea0a0.tar.bz2 rails-01839834fd19e7be1e89309416bed497ac5ea0a0.zip |
ControllerRuntime tests also use Rails::Subscriber::TestHelper.
Diffstat (limited to 'actionpack/test/activerecord')
-rw-r--r-- | actionpack/test/activerecord/controller_runtime_test.rb | 49 |
1 files changed, 32 insertions, 17 deletions
diff --git a/actionpack/test/activerecord/controller_runtime_test.rb b/actionpack/test/activerecord/controller_runtime_test.rb index 9525dd8307..6c9a24a760 100644 --- a/actionpack/test/activerecord/controller_runtime_test.rb +++ b/actionpack/test/activerecord/controller_runtime_test.rb @@ -1,38 +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 - # Wait pending notifications to be published - wait get :show wait - assert_match /ActiveRecord runtime/, @controller.logger.logged[3] + + assert_equal 4, @logger.logged(:info).size + assert_match /ActiveRecord runtime/, @logger.logged(:info)[2] end - private - def set_logger - @controller.logger = MockLogger.new - end + class SyncSubscriberTest < ActionController::TestCase + include Rails::Subscriber::SyncTestHelper + include ControllerRuntimeSubscriberTest + end -end + class AsyncSubscriberTest < ActionController::TestCase + include Rails::Subscriber::AsyncTestHelper + include ControllerRuntimeSubscriberTest + end +end
\ No newline at end of file |