From c88360ef3651702ca8f7f600e15774f51c84698b Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Mon, 1 Mar 2010 16:01:08 -0800 Subject: You can unsubscribe a subscriber --- activesupport/test/notifications_test.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'activesupport/test') 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 -- cgit v1.2.3