mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
ActiveSupport::Notifications::Instrumenter#instrument should yield
its payload the same way that ActiveSupport::Notifications does. Fix spelling in test name.
This commit is contained in:
parent
8fe904b5ca
commit
a007800a55
4 changed files with 16 additions and 3 deletions
|
@ -1,5 +1,10 @@
|
|||
## Rails 4.0.0 (unreleased) ##
|
||||
|
||||
* `ActiveSupport::Notifications::Instrumenter#instrument` should yield
|
||||
its payload.
|
||||
|
||||
*stopdropandrew*
|
||||
|
||||
* Fix deletion of empty directories in ActiveSupport::Cache::FileStore.
|
||||
|
||||
*Charles Jones*
|
||||
|
|
|
@ -17,7 +17,7 @@ module ActiveSupport
|
|||
def instrument(name, payload={})
|
||||
start name, payload
|
||||
begin
|
||||
yield
|
||||
yield payload
|
||||
rescue Exception => e
|
||||
payload[:exception] = [e.class.name, e.message]
|
||||
raise e
|
||||
|
|
|
@ -34,6 +34,14 @@ module ActiveSupport
|
|||
assert called
|
||||
end
|
||||
|
||||
def test_instrument_yields_the_payload_for_further_modification
|
||||
assert_equal 2, instrumenter.instrument("awesome") { |p| p[:result] = 1 + 1 }
|
||||
assert_equal 1, notifier.finishes.size
|
||||
name, _, payload = notifier.finishes.first
|
||||
assert_equal "awesome", name
|
||||
assert_equal Hash[:result => 2], payload
|
||||
end
|
||||
|
||||
def test_start
|
||||
instrumenter.start("foo", payload)
|
||||
assert_equal [["foo", instrumenter.id, payload]], notifier.starts
|
||||
|
|
|
@ -157,7 +157,7 @@ module Notifications
|
|||
assert_equal 2, instrument(:awesome) { 1 + 1 }
|
||||
end
|
||||
|
||||
def test_instrument_yields_the_paylod_for_further_modification
|
||||
def test_instrument_yields_the_payload_for_further_modification
|
||||
assert_equal 2, instrument(:awesome) { |p| p[:result] = 1 + 1 }
|
||||
assert_equal 1, @events.size
|
||||
assert_equal :awesome, @events.first.name
|
||||
|
|
Loading…
Reference in a new issue