aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/activerecord
diff options
context:
space:
mode:
authorMikel Lindsaar <raasdnil@gmail.com>2010-01-17 12:46:51 +1100
committerMikel Lindsaar <raasdnil@gmail.com>2010-01-17 12:46:51 +1100
commit6f663addaa7ed40f1133687d7a2be0958bf0c059 (patch)
tree7beb7f092c1979d1fd5ea6e7aaaf4f59c2f4abf4 /actionpack/test/activerecord
parent8834b2612b7ddda70ee6a685eb0063d3daa8e63d (diff)
parent3e94032227d450d479f511070c51f37f53d0ecc4 (diff)
downloadrails-6f663addaa7ed40f1133687d7a2be0958bf0c059.tar.gz
rails-6f663addaa7ed40f1133687d7a2be0958bf0c059.tar.bz2
rails-6f663addaa7ed40f1133687d7a2be0958bf0c059.zip
Merge branch 'master' of github.com:lifo/docrails
Diffstat (limited to 'actionpack/test/activerecord')
-rw-r--r--actionpack/test/activerecord/controller_runtime_test.rb50
-rw-r--r--actionpack/test/activerecord/polymorphic_routes_test.rb2
2 files changed, 33 insertions, 19 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
diff --git a/actionpack/test/activerecord/polymorphic_routes_test.rb b/actionpack/test/activerecord/polymorphic_routes_test.rb
index ad744421db..ea82758cf5 100644
--- a/actionpack/test/activerecord/polymorphic_routes_test.rb
+++ b/actionpack/test/activerecord/polymorphic_routes_test.rb
@@ -26,7 +26,7 @@ class Series < ActiveRecord::Base
end
class PolymorphicRoutesTest < ActionController::TestCase
- include ActionController::UrlWriter
+ include ActionController::UrlFor
self.default_url_options[:host] = 'example.com'
def setup