diff options
Diffstat (limited to 'activesupport/test/notifications_test.rb')
-rw-r--r-- | activesupport/test/notifications_test.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/activesupport/test/notifications_test.rb b/activesupport/test/notifications_test.rb index 884ee61547..fc9fa90d07 100644 --- a/activesupport/test/notifications_test.rb +++ b/activesupport/test/notifications_test.rb @@ -24,6 +24,26 @@ module Notifications end end + class SubscribedTest < TestCase + def test_subscribed + name = "foo" + name2 = name * 2 + expected = [name, name] + + events = [] + callback = lambda {|*_| events << _.first} + ActiveSupport::Notifications.subscribed(callback, name) do + ActiveSupport::Notifications.instrument(name) + ActiveSupport::Notifications.instrument(name2) + ActiveSupport::Notifications.instrument(name) + end + assert_equal expected, events + + ActiveSupport::Notifications.instrument(name) + assert_equal expected, events + end + end + class UnsubscribeTest < TestCase def test_unsubscribing_removes_a_subscription @notifier.publish :foo |