File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed
actionpack/test/controller Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -601,6 +601,23 @@ def test_url_from_fallback
601601 end
602602 end
603603
604+ def test_redirect_to_instrumentation
605+ payload = nil
606+
607+ subscriber = proc do |*args |
608+ event = ActiveSupport ::Notifications ::Event . new ( *args )
609+ payload = event . payload
610+ end
611+
612+ ActiveSupport ::Notifications . subscribed ( subscriber , "redirect_to.action_controller" ) do
613+ get :simple_redirect
614+ end
615+
616+ assert_equal request , payload [ :request ]
617+ assert_equal 302 , payload [ :status ]
618+ assert_equal "http://test.host/redirect/hello_world" , payload [ :location ]
619+ end
620+
604621 private
605622 def with_raise_on_open_redirects
606623 old_raise_on_open_redirects = ActionController ::Base . raise_on_open_redirects
Original file line number Diff line number Diff line change @@ -207,6 +207,36 @@ def test_send_file_from_before_action
207207 assert_equal file_data , response . body
208208 end
209209
210+ def test_send_file_instrumentation
211+ payload = nil
212+
213+ subscriber = proc do |*args |
214+ event = ActiveSupport ::Notifications ::Event . new ( *args )
215+ payload = event . payload
216+ end
217+
218+ ActiveSupport ::Notifications . subscribed ( subscriber , "send_file.action_controller" ) do
219+ process ( "file" )
220+ end
221+
222+ assert_equal __FILE__ , payload [ :path ]
223+ end
224+
225+ def test_send_data_instrumentation
226+ payload = nil
227+
228+ subscriber = proc do |*args |
229+ event = ActiveSupport ::Notifications ::Event . new ( *args )
230+ payload = event . payload
231+ end
232+
233+ ActiveSupport ::Notifications . subscribed ( subscriber , "send_data.action_controller" ) do
234+ process ( "data" )
235+ end
236+
237+ assert_equal ( { } , payload )
238+ end
239+
210240 %w( file data ) . each do |method |
211241 define_method "test_send_#{ method } _status" do
212242 @controller . options = { stream : false , status : 500 }
You can’t perform that action at this time.
0 commit comments