aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/notifications_test.rb31
1 files changed, 29 insertions, 2 deletions
diff --git a/activesupport/test/notifications_test.rb b/activesupport/test/notifications_test.rb
index baee779b8a..67c3527e23 100644
--- a/activesupport/test/notifications_test.rb
+++ b/activesupport/test/notifications_test.rb
@@ -20,15 +20,20 @@ module Notifications
end
class UnsubscribeTest < TestCase
- def unsubscribing_removes_a_subscription
+ def test_unsubscribing_removes_a_subscription
@notifier.publish :foo
@notifier.wait
assert_equal [[:foo]], @events
@notifier.unsubscribe(@subscription)
- @notifier.publish :bar
+ @notifier.publish :foo
@notifier.wait
assert_equal [[:foo]], @events
end
+
+ private
+ def event(*args)
+ args
+ end
end
class SyncPubSubTest < TestCase
@@ -38,6 +43,28 @@ module Notifications
assert_equal [[:foo]], @events
end
+ def test_publishing_multiple_times_works
+ @notifier.publish :foo
+ @notifier.publish :foo
+ @notifier.wait
+ assert_equal [[:foo], [:foo]], @events
+ end
+
+ def test_publishing_after_a_new_subscribe_works
+ @notifier.publish :foo
+ @notifier.publish :foo
+
+ @notifier.subscribe("not_existant") do |*args|
+ @events << ActiveSupport::Notifications::Event.new(*args)
+ end
+
+ @notifier.publish :foo
+ @notifier.publish :foo
+ @notifier.wait
+
+ assert_equal [[:foo]] * 4, @events
+ end
+
def test_log_subscriber_with_pattern
events = []
@notifier.subscribe('1') { |*args| events << args }