Skip to content

Commit 1edf65d

Browse files
authored
Merge pull request rails#49467 from p8/actionpack/notifications-tests2
Improve instrumentation tests
2 parents 7cc4de0 + 9c96042 commit 1edf65d

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

actionpack/test/controller/caching_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@ def test_render_inline_before_fragment_caching
257257
def test_fragment_cache_instrumentation
258258
payload = nil
259259

260-
subscriber = proc do |_, _, _, _, event_payload|
261-
payload = event_payload
260+
subscriber = proc do |event|
261+
payload = event.payload
262262
end
263263

264264
ActiveSupport::Notifications.subscribed(subscriber, "read_fragment.action_controller") do

actionpack/test/controller/redirect_test.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,8 +604,7 @@ def test_url_from_fallback
604604
def test_redirect_to_instrumentation
605605
payload = nil
606606

607-
subscriber = proc do |*args|
608-
event = ActiveSupport::Notifications::Event.new(*args)
607+
subscriber = proc do |event|
609608
payload = event.payload
610609
end
611610

actionpack/test/controller/send_file_test.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,10 @@ def test_send_file_from_before_action
208208
end
209209

210210
def test_send_file_instrumentation
211+
@controller.options = { disposition: :inline }
211212
payload = nil
212213

213-
subscriber = proc do |*args|
214-
event = ActiveSupport::Notifications::Event.new(*args)
214+
subscriber = proc do |event|
215215
payload = event.payload
216216
end
217217

@@ -220,21 +220,22 @@ def test_send_file_instrumentation
220220
end
221221

222222
assert_equal __FILE__, payload[:path]
223+
assert_equal :inline, payload[:disposition]
223224
end
224225

225226
def test_send_data_instrumentation
227+
@controller.options = { content_type: "application/x-ruby" }
226228
payload = nil
227229

228-
subscriber = proc do |*args|
229-
event = ActiveSupport::Notifications::Event.new(*args)
230+
subscriber = proc do |event|
230231
payload = event.payload
231232
end
232233

233234
ActiveSupport::Notifications.subscribed(subscriber, "send_data.action_controller") do
234235
process("data")
235236
end
236237

237-
assert_equal({}, payload)
238+
assert_equal("application/x-ruby", payload[:content_type])
238239
end
239240

240241
%w(file data).each do |method|

0 commit comments

Comments
 (0)