aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-06-03 05:47:10 +0900
committerRyuta Kamizono <kamipo@gmail.com>2019-06-03 05:47:10 +0900
commit90d6237762da832d0c6302b31fd68d3efb771c64 (patch)
tree8147e46c31395e9a0db3cb60ef38dcc34ad50119 /activesupport/test
parentc3ca9b00e3c5f839311c55549f25f7afe8120f9d (diff)
downloadrails-90d6237762da832d0c6302b31fd68d3efb771c64.tar.gz
rails-90d6237762da832d0c6302b31fd68d3efb771c64.tar.bz2
rails-90d6237762da832d0c6302b31fd68d3efb771c64.zip
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.
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/notifications_test.rb18
1 files changed, 18 insertions, 0 deletions
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