From 90d6237762da832d0c6302b31fd68d3efb771c64 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Mon, 3 Jun 2019 05:47:10 +0900 Subject: Fix `subscribed` with no pattern to subscribe all messages This is a regression for #36184. And also, add new `monotonic` argument to the last of the method signature rather than the first. --- activesupport/test/notifications_test.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'activesupport/test') diff --git a/activesupport/test/notifications_test.rb b/activesupport/test/notifications_test.rb index 3b98749f1b..02b90b0297 100644 --- a/activesupport/test/notifications_test.rb +++ b/activesupport/test/notifications_test.rb @@ -113,6 +113,24 @@ module Notifications assert_equal expected, events end + def test_subscribed_all_messages + name = "foo" + name2 = name * 2 + expected = [name, name2, name] + + events = [] + callback = lambda { |*_| events << _.first } + ActiveSupport::Notifications.subscribed(callback) 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 + def test_subscribing_to_instrumentation_while_inside_it # the repro requires that there are no evented subscribers for the "foo" event, # so we have to duplicate some of the setup code -- cgit v1.2.3