aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorYehuda Katz <wycats@gmail.com>2009-10-28 01:58:33 -0700
committerYehuda Katz <wycats@gmail.com>2009-10-28 01:58:33 -0700
commitc9487ed6aff76693f33ff89e466ba944297681d3 (patch)
tree9620f225535a2adab27b5a2399f69427ec1cd5d5 /activesupport/test
parent03d3824d965f38d3c595330d697fb16dc9efdb9a (diff)
downloadrails-c9487ed6aff76693f33ff89e466ba944297681d3.tar.gz
rails-c9487ed6aff76693f33ff89e466ba944297681d3.tar.bz2
rails-c9487ed6aff76693f33ff89e466ba944297681d3.zip
Change Event#thread_id to #transaction_id. Defaults to one "transaction" per thread but you can explicitly declare the start of a new one. This makes it possible for each request to have it own id.
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/notifications_test.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/activesupport/test/notifications_test.rb b/activesupport/test/notifications_test.rb
index b763b740af..9175c8f26e 100644
--- a/activesupport/test/notifications_test.rb
+++ b/activesupport/test/notifications_test.rb
@@ -124,6 +124,26 @@ class NotificationsMainTest < Test::Unit::TestCase
assert_equal Hash[:payload => "notifications"], @events.last.payload
end
+ def test_subscribed_in_a_transaction
+ @another = []
+
+ ActiveSupport::Notifications.subscribe("cache") do |*args|
+ @another << ActiveSupport::Notifications::Event.new(*args)
+ end
+
+ ActiveSupport::Notifications.instrument(:cache){ 1 }
+ ActiveSupport::Notifications.transaction do
+ ActiveSupport::Notifications.instrument(:cache){ 1 }
+ end
+ ActiveSupport::Notifications.instrument(:cache){ 1 }
+
+ sleep 0.1
+
+ before, during, after = @another.map {|e| e.transaction_id }
+ assert_equal before, after
+ assert_not_equal before, during
+ end
+
def test_subscriber_with_pattern
@another = []