aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorCarlhuda <carlhuda@engineyard.com>2010-03-01 16:01:08 -0800
committerCarlhuda <carlhuda@engineyard.com>2010-03-01 17:45:37 -0800
commitc88360ef3651702ca8f7f600e15774f51c84698b (patch)
tree2582399b60fac70eba83ea3988a82c72c98e53f3 /activesupport/test
parent048b436f33059f1da7659edf9ca05fb46042b253 (diff)
downloadrails-c88360ef3651702ca8f7f600e15774f51c84698b.tar.gz
rails-c88360ef3651702ca8f7f600e15774f51c84698b.tar.bz2
rails-c88360ef3651702ca8f7f600e15774f51c84698b.zip
You can unsubscribe a subscriber
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/notifications_test.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/activesupport/test/notifications_test.rb b/activesupport/test/notifications_test.rb
index 779771553c..baee779b8a 100644
--- a/activesupport/test/notifications_test.rb
+++ b/activesupport/test/notifications_test.rb
@@ -6,7 +6,7 @@ module Notifications
ActiveSupport::Notifications.notifier = nil
@notifier = ActiveSupport::Notifications.notifier
@events = []
- @notifier.subscribe { |*args| @events << event(*args) }
+ @subscription = @notifier.subscribe { |*args| @events << event(*args) }
end
private
@@ -19,6 +19,18 @@ module Notifications
end
end
+ class UnsubscribeTest < TestCase
+ def unsubscribing_removes_a_subscription
+ @notifier.publish :foo
+ @notifier.wait
+ assert_equal [[:foo]], @events
+ @notifier.unsubscribe(@subscription)
+ @notifier.publish :bar
+ @notifier.wait
+ assert_equal [[:foo]], @events
+ end
+ end
+
class SyncPubSubTest < TestCase
def test_events_are_published_to_a_listener
@notifier.publish :foo