aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-01-03 20:39:42 +0100
committerJosé Valim <jose.valim@gmail.com>2010-01-03 20:39:42 +0100
commit6fbe9ef2ffb1858027130789246f3ae24a0a182f (patch)
tree6926a804d3b78021e421470518bf10d2ca919ef9 /actionpack/test
parent4796be33a464a4587d0e22dfef113aca597c91c4 (diff)
downloadrails-6fbe9ef2ffb1858027130789246f3ae24a0a182f.tar.gz
rails-6fbe9ef2ffb1858027130789246f3ae24a0a182f.tar.bz2
rails-6fbe9ef2ffb1858027130789246f3ae24a0a182f.zip
Use namespaces in notifications.
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/abstract_unit.rb5
-rw-r--r--actionpack/test/activerecord/controller_runtime_test.rb5
-rw-r--r--actionpack/test/controller/caching_test.rb14
-rw-r--r--actionpack/test/controller/logging_test.rb2
4 files changed, 12 insertions, 14 deletions
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