aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/notifications_test.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-11-22 10:31:47 -0800
committerJeremy Kemper <jeremy@bitsweat.net>2009-11-22 10:31:47 -0800
commite68bc3f14ea93eabdd4274e66071b65debb5a0a8 (patch)
tree223c11f38dac1217d8e7e3cd427fdf6018975a9d /activesupport/test/notifications_test.rb
parent3cb46b40a0df1a1f4912625cc2be40b3d630f1f3 (diff)
parente1935e3c0c35f8f1196239e2b1213c4436049fa5 (diff)
downloadrails-e68bc3f14ea93eabdd4274e66071b65debb5a0a8.tar.gz
rails-e68bc3f14ea93eabdd4274e66071b65debb5a0a8.tar.bz2
rails-e68bc3f14ea93eabdd4274e66071b65debb5a0a8.zip
Merge commit 'origin/master' into mail
Diffstat (limited to 'activesupport/test/notifications_test.rb')
-rw-r--r--activesupport/test/notifications_test.rb25
1 files changed, 15 insertions, 10 deletions
diff --git a/activesupport/test/notifications_test.rb b/activesupport/test/notifications_test.rb
index 9175c8f26e..01106e83e9 100644
--- a/activesupport/test/notifications_test.rb
+++ b/activesupport/test/notifications_test.rb
@@ -75,7 +75,7 @@ class NotificationsMainTest < Test::Unit::TestCase
1 + 1
end
- sleep(0.1)
+ drain
assert_equal 1, @events.size
assert_equal :awesome, @events.last.name
@@ -88,19 +88,18 @@ class NotificationsMainTest < Test::Unit::TestCase
1 + 1
end
- sleep(0.1)
+ drain
assert_equal 1, @events.size
assert_equal :wot, @events.first.name
assert_equal Hash[:payload => "child"], @events.first.payload
end
- sleep(0.1)
+ drain
assert_equal 2, @events.size
assert_equal :awesome, @events.last.name
assert_equal Hash[:payload => "notifications"], @events.last.payload
- assert_in_delta 100, @events.last.duration, 70
end
def test_event_is_pushed_even_if_block_fails
@@ -108,7 +107,7 @@ class NotificationsMainTest < Test::Unit::TestCase
raise "OMG"
end rescue RuntimeError
- sleep(0.1)
+ drain
assert_equal 1, @events.size
assert_equal :awesome, @events.last.name
@@ -117,7 +116,7 @@ class NotificationsMainTest < Test::Unit::TestCase
def test_event_is_pushed_even_without_block
ActiveSupport::Notifications.instrument(:awesome, :payload => "notifications")
- sleep(0.1)
+ drain
assert_equal 1, @events.size
assert_equal :awesome, @events.last.name
@@ -137,8 +136,9 @@ class NotificationsMainTest < Test::Unit::TestCase
end
ActiveSupport::Notifications.instrument(:cache){ 1 }
- sleep 0.1
+ drain
+ assert_equal 3, @another.size
before, during, after = @another.map {|e| e.transaction_id }
assert_equal before, after
assert_not_equal before, during
@@ -153,7 +153,7 @@ class NotificationsMainTest < Test::Unit::TestCase
ActiveSupport::Notifications.instrument(:cache){ 1 }
- sleep(0.1)
+ drain
assert_equal 1, @another.size
assert_equal :cache, @another.first.name
@@ -169,7 +169,7 @@ class NotificationsMainTest < Test::Unit::TestCase
ActiveSupport::Notifications.instrument(:something){ 0 }
ActiveSupport::Notifications.instrument(:cache){ 1 }
- sleep(0.1)
+ drain
assert_equal 1, @another.size
assert_equal :cache, @another.first.name
@@ -186,7 +186,7 @@ class NotificationsMainTest < Test::Unit::TestCase
ActiveSupport::Notifications.instrument(:value){ i }
end
- sleep 0.1
+ drain
assert_equal 100, @events.size
assert_equal :value, @events.first.name
@@ -198,4 +198,9 @@ class NotificationsMainTest < Test::Unit::TestCase
assert_equal 1, @another.first.result
assert_equal 100, @another.last.result
end
+
+ private
+ def drain
+ sleep(0.1) until ActiveSupport::Notifications.queue.drained?
+ end
end