diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2018-07-26 12:05:23 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2018-07-26 12:05:23 -0700 |
commit | 5e0c423881985abfcbeffa602ee0d15467e24bf7 (patch) | |
tree | b8a68fbc69938adde0d2d6e77aa08ddc3cdbc33e | |
parent | b0a16a97762c4cdcf36403d46968930099ddcd0f (diff) | |
download | rails-5e0c423881985abfcbeffa602ee0d15467e24bf7.tar.gz rails-5e0c423881985abfcbeffa602ee0d15467e24bf7.tar.bz2 rails-5e0c423881985abfcbeffa602ee0d15467e24bf7.zip |
Subscribe to event objects via `subscribe`
-rw-r--r-- | activesupport/test/notifications_test.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activesupport/test/notifications_test.rb b/activesupport/test/notifications_test.rb index e28560d88b..119062d5bf 100644 --- a/activesupport/test/notifications_test.rb +++ b/activesupport/test/notifications_test.rb @@ -41,6 +41,18 @@ module Notifications assert_operator event.idle_time, :>, 0 assert_operator event.duration, :>, 0 end + + def test_subscribe_via_subscribe_method + events = [] + @notifier.subscribe do |event| + events << event + end + + ActiveSupport::Notifications.instrument("foo") + event = events.first + assert event, "should have an event" + assert_operator event.allocations, :>, 0 + end end class SubscribedTest < TestCase |