From 6fbe9ef2ffb1858027130789246f3ae24a0a182f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sun, 3 Jan 2010 20:39:42 +0100 Subject: Use namespaces in notifications. --- actionpack/test/abstract_unit.rb | 5 ++++- actionpack/test/activerecord/controller_runtime_test.rb | 5 +---- actionpack/test/controller/caching_test.rb | 14 ++++++-------- actionpack/test/controller/logging_test.rb | 2 +- 4 files changed, 12 insertions(+), 14 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb index 8c65087898..c1aebefc77 100644 --- a/actionpack/test/abstract_unit.rb +++ b/actionpack/test/abstract_unit.rb @@ -96,7 +96,6 @@ class ActiveSupport::TestCase end class MockLogger - attr_reader :logged attr_accessor :level def initialize @@ -108,6 +107,10 @@ class MockLogger @logged << args.first @logged << blk.call if block_given? end + + def logged + @logged.compact.map { |l| l.to_s.strip } + end end class ActionController::IntegrationTest < ActiveSupport::TestCase diff --git a/actionpack/test/activerecord/controller_runtime_test.rb b/actionpack/test/activerecord/controller_runtime_test.rb index 0f534da14b..6f30bec8ee 100644 --- a/actionpack/test/activerecord/controller_runtime_test.rb +++ b/actionpack/test/activerecord/controller_runtime_test.rb @@ -25,7 +25,7 @@ class ARLoggingTest < ActionController::TestCase def test_log_with_active_record get :show wait - assert_match /ActiveRecord runtime/, logs[3] + assert_match /ActiveRecord runtime/, @controller.logger.logged[3] end private @@ -33,7 +33,4 @@ class ARLoggingTest < ActionController::TestCase @controller.logger = MockLogger.new end - def logs - @logs ||= @controller.logger.logged.compact.map {|l| l.to_s.strip} - end end diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb index 679eaf7b38..54d1a72f1f 100644 --- a/actionpack/test/controller/caching_test.rb +++ b/actionpack/test/controller/caching_test.rb @@ -630,17 +630,15 @@ class FragmentCachingTest < ActionController::TestCase end def test_fragment_for_logging - fragment_computed = false - events = [] - ActiveSupport::Notifications.subscribe { |*args| events << args } + @controller.logger = MockLogger.new - buffer = 'generated till now -> ' - @controller.fragment_for(buffer, 'expensive') { fragment_computed = true } + fragment_computed = false + @controller.fragment_for('buffer', 'expensive') { fragment_computed = true } + ActiveSupport::Notifications.notifier.wait assert fragment_computed - assert_equal 'generated till now -> ', buffer - ActiveSupport::Notifications.notifier.wait - assert_equal [:exist_fragment?, :write_fragment], events.map(&:first) + assert_match /Exist fragment\? "views\/expensive"/, @controller.logger.logged[0] + assert_match /Write fragment "views\/expensive"/, @controller.logger.logged[1] end end diff --git a/actionpack/test/controller/logging_test.rb b/actionpack/test/controller/logging_test.rb index 4206dffa7e..6b9db88d83 100644 --- a/actionpack/test/controller/logging_test.rb +++ b/actionpack/test/controller/logging_test.rb @@ -75,6 +75,6 @@ class LoggingTest < ActionController::TestCase end def logs - @logs ||= @controller.logger.logged.compact.map {|l| l.to_s.strip} + @logs ||= @controller.logger.logged end end -- cgit v1.2.3