aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-11-19 14:50:27 -0200
committerYehuda Katz <wycats@Yehuda-Katz.local>2009-11-23 09:08:17 -0800
commit8104f65c3225453d13307c3c2733c2a8f99e491a (patch)
tree433b697be24ca3f8cfeab45add6a5e1939a668fe /activesupport/test
parent0f9029ec4854c8dfa14e75ea646708ba5135fbf2 (diff)
downloadrails-8104f65c3225453d13307c3c2733c2a8f99e491a.tar.gz
rails-8104f65c3225453d13307c3c2733c2a8f99e491a.tar.bz2
rails-8104f65c3225453d13307c3c2733c2a8f99e491a.zip
Create SyncListener. Since they do not rely on Thread, they can be used on Google App Engine.
Signed-off-by: Yehuda Katz <wycats@Yehuda-Katz.local>
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/notifications_test.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/activesupport/test/notifications_test.rb b/activesupport/test/notifications_test.rb
index 01106e83e9..35d44367cf 100644
--- a/activesupport/test/notifications_test.rb
+++ b/activesupport/test/notifications_test.rb
@@ -176,6 +176,21 @@ class NotificationsMainTest < Test::Unit::TestCase
assert_equal 1, @another.first.result
end
+ def test_subscriber_allows_sync_listeners
+ @another = []
+ ActiveSupport::Notifications.subscribe(/cache/, :with => ActiveSupport::Notifications::SyncListener) do |*args|
+ @another << ActiveSupport::Notifications::Event.new(*args)
+ end
+
+ Thread.expects(:new).never
+ ActiveSupport::Notifications.instrument(:something){ 0 }
+ ActiveSupport::Notifications.instrument(:cache){ 1 }
+
+ assert_equal 1, @another.size
+ assert_equal :cache, @another.first.name
+ assert_equal 1, @another.first.result
+ end
+
def test_with_several_consumers_and_several_events
@another = []
ActiveSupport::Notifications.subscribe do |*args|
@@ -201,6 +216,6 @@ class NotificationsMainTest < Test::Unit::TestCase
private
def drain
- sleep(0.1) until ActiveSupport::Notifications.queue.drained?
+ sleep(0.05) until ActiveSupport::Notifications.queue.drained?
end
end