Improve instrumentation tests

Don't build AS::Notifications::Event manually, similar to 95b6fbd00f
Also assert that options get passed.
This commit is contained in:
Petrik 2023-10-03 08:11:51 +02:00
parent a9fa57e1d1
commit 9c96042690
3 changed files with 9 additions and 9 deletions

View File

@ -257,8 +257,8 @@ Ciao
def test_fragment_cache_instrumentation
payload = nil
subscriber = proc do |_, _, _, _, event_payload|
payload = event_payload
subscriber = proc do |event|
payload = event.payload
end
ActiveSupport::Notifications.subscribed(subscriber, "read_fragment.action_controller") do

View File

@ -604,8 +604,7 @@ class RedirectTest < ActionController::TestCase
def test_redirect_to_instrumentation
payload = nil
subscriber = proc do |*args|
event = ActiveSupport::Notifications::Event.new(*args)
subscriber = proc do |event|
payload = event.payload
end

View File

@ -208,10 +208,10 @@ class SendFileTest < ActionController::TestCase
end
def test_send_file_instrumentation
@controller.options = { disposition: :inline }
payload = nil
subscriber = proc do |*args|
event = ActiveSupport::Notifications::Event.new(*args)
subscriber = proc do |event|
payload = event.payload
end
@ -220,13 +220,14 @@ class SendFileTest < ActionController::TestCase
end
assert_equal __FILE__, payload[:path]
assert_equal :inline, payload[:disposition]
end
def test_send_data_instrumentation
@controller.options = { content_type: "application/x-ruby" }
payload = nil
subscriber = proc do |*args|
event = ActiveSupport::Notifications::Event.new(*args)
subscriber = proc do |event|
payload = event.payload
end
@ -234,7 +235,7 @@ class SendFileTest < ActionController::TestCase
process("data")
end
assert_equal({}, payload)
assert_equal("application/x-ruby", payload[:content_type])
end
%w(file data).each do |method|