aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/notifications/evented_notification_test.rb
diff options
context:
space:
mode:
authorEric Saxby <sax@livinginthepast.org>2012-08-11 17:39:20 -0700
committerEric Saxby <sax@livinginthepast.org>2012-08-11 17:39:20 -0700
commit6fe36ba585d7d60d127b3ba75f923a48c132b3bb (patch)
tree5952b944b2a021c16e87252be1e263e6901826c3 /activesupport/test/notifications/evented_notification_test.rb
parenta513cc1862cc61fd9605352a58c5e36cc40cb574 (diff)
downloadrails-6fe36ba585d7d60d127b3ba75f923a48c132b3bb.tar.gz
rails-6fe36ba585d7d60d127b3ba75f923a48c132b3bb.tar.bz2
rails-6fe36ba585d7d60d127b3ba75f923a48c132b3bb.zip
Evented notifications take priority over Timed notifications
In cases where a notification subscriber includes methods to support both Evented and Timed events, Evented should take priority over Timed. This allows subscribers to be backwards compatible (older Rails only allows Timed events) while defaulting to newer behavior.
Diffstat (limited to 'activesupport/test/notifications/evented_notification_test.rb')
-rw-r--r--activesupport/test/notifications/evented_notification_test.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/activesupport/test/notifications/evented_notification_test.rb b/activesupport/test/notifications/evented_notification_test.rb
index f77a0eb3fa..f690ad43fc 100644
--- a/activesupport/test/notifications/evented_notification_test.rb
+++ b/activesupport/test/notifications/evented_notification_test.rb
@@ -19,6 +19,12 @@ module ActiveSupport
end
end
+ class ListenerWithTimedSupport < Listener
+ def call(name, start, finish, id, payload)
+ @events << [:call, name, start, finish, id, payload]
+ end
+ end
+
def test_evented_listener
notifier = Fanout.new
listener = Listener.new
@@ -62,6 +68,20 @@ module ActiveSupport
[:finish, 'hello', 1, {}],
], listener.events
end
+
+ def test_evented_listener_priority
+ notifier = Fanout.new
+ listener = ListenerWithTimedSupport.new
+ notifier.subscribe 'hi', listener
+
+ notifier.start 'hi', 1, {}
+ notifier.finish 'hi', 1, {}
+
+ assert_equal [
+ [:start, 'hi', 1, {}],
+ [:finish, 'hi', 1, {}]
+ ], listener.events
+ end
end
end
end