aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/notifications_test.rb
diff options
context:
space:
mode:
authorCarl Lerche <me@carllerche.com>2013-05-17 16:27:23 -0700
committerCarl Lerche <me@carllerche.com>2013-05-17 16:27:23 -0700
commite539228d088c4e9de5bbc24bd82fb2d894d8c158 (patch)
treecc7748f0828e559882f281250365128357895cc1 /activesupport/test/notifications_test.rb
parent18fe96cc168927a6508478f9ad127d57c1ad56dd (diff)
downloadrails-e539228d088c4e9de5bbc24bd82fb2d894d8c158.tar.gz
rails-e539228d088c4e9de5bbc24bd82fb2d894d8c158.tar.bz2
rails-e539228d088c4e9de5bbc24bd82fb2d894d8c158.zip
Bug fix: Evented notification subscribers can handle published events
Diffstat (limited to 'activesupport/test/notifications_test.rb')
-rw-r--r--activesupport/test/notifications_test.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/activesupport/test/notifications_test.rb b/activesupport/test/notifications_test.rb
index 33627a4e74..f729f0a95b 100644
--- a/activesupport/test/notifications_test.rb
+++ b/activesupport/test/notifications_test.rb
@@ -81,6 +81,20 @@ module Notifications
end
end
+ class TestSubscriber
+ attr_reader :starts, :finishes, :publishes
+
+ def initialize
+ @starts = []
+ @finishes = []
+ @publishes = []
+ end
+
+ def start(*args); @starts << args; end
+ def finish(*args); @finishes << args; end
+ def publish(*args); @publishes << args; end
+ end
+
class SyncPubSubTest < TestCase
def test_events_are_published_to_a_listener
@notifier.publish :foo
@@ -144,6 +158,14 @@ module Notifications
assert_equal [[:foo]], @another
end
+ def test_publish_with_subscriber
+ subscriber = TestSubscriber.new
+ @notifier.subscribe nil, subscriber
+ @notifier.publish :foo
+
+ assert_equal [[:foo]], subscriber.publishes
+ end
+
private
def event(*args)
args