diff options
author | wycats <wycats@gmail.com> | 2010-04-26 23:32:30 -0700 |
---|---|---|
committer | wycats <wycats@gmail.com> | 2010-04-26 23:32:30 -0700 |
commit | 91963e9e33eb5a28297323f1346aeb8b643e9d65 (patch) | |
tree | 0452dbaf63110fb5a19c958da50d4677dee11333 /activesupport/test/notifications_test.rb | |
parent | d5d717161d853d8d7240da59b41a879bdac6e982 (diff) | |
parent | c1d73270717f30498f8f4d55d6695509107c2834 (diff) | |
download | rails-91963e9e33eb5a28297323f1346aeb8b643e9d65.tar.gz rails-91963e9e33eb5a28297323f1346aeb8b643e9d65.tar.bz2 rails-91963e9e33eb5a28297323f1346aeb8b643e9d65.zip |
Merge branch 'master' of github.com:rails/rails
Diffstat (limited to 'activesupport/test/notifications_test.rb')
-rw-r--r-- | activesupport/test/notifications_test.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/activesupport/test/notifications_test.rb b/activesupport/test/notifications_test.rb index 92fbe5b92f..c2e1c588f0 100644 --- a/activesupport/test/notifications_test.rb +++ b/activesupport/test/notifications_test.rb @@ -6,7 +6,9 @@ module Notifications ActiveSupport::Notifications.notifier = nil @notifier = ActiveSupport::Notifications.notifier @events = [] + @named_events = [] @subscription = @notifier.subscribe { |*args| @events << event(*args) } + @named_subscription = @notifier.subscribe("named.subscription") { |*args| @named_events << event(*args) } end private @@ -30,6 +32,26 @@ module Notifications assert_equal [[:foo]], @events end + def test_unsubscribing_by_name_removes_a_subscription + @notifier.publish "named.subscription", :foo + @notifier.wait + assert_equal [["named.subscription", :foo]], @named_events + @notifier.unsubscribe("named.subscription") + @notifier.publish "named.subscription", :foo + @notifier.wait + assert_equal [["named.subscription", :foo]], @named_events + end + + def test_unsubscribing_by_name_leaves_the_other_subscriptions + @notifier.publish "named.subscription", :foo + @notifier.wait + assert_equal [["named.subscription", :foo]], @events + @notifier.unsubscribe("named.subscription") + @notifier.publish "named.subscription", :foo + @notifier.wait + assert_equal [["named.subscription", :foo], ["named.subscription", :foo]], @events + end + private def event(*args) args |