From 5e0c423881985abfcbeffa602ee0d15467e24bf7 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 26 Jul 2018 12:05:23 -0700 Subject: Subscribe to event objects via `subscribe` --- activesupport/test/notifications_test.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 -- cgit v1.2.3