File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -159,6 +159,7 @@ def request_method
159
159
def route_uri_pattern
160
160
unless pattern = get_header ( "action_dispatch.route_uri_pattern" )
161
161
route = get_header ( "action_dispatch.route" )
162
+ return if route . nil?
162
163
pattern = route . path . spec . to_s
163
164
set_header ( "action_dispatch.route_uri_pattern" , pattern )
164
165
end
Original file line number Diff line number Diff line change @@ -72,6 +72,29 @@ def action_missing(action)
72
72
end
73
73
end
74
74
75
+ class WithoutRouterController < ActionController ::Base
76
+ after_action :log_request_details
77
+
78
+ def index
79
+ head :ok
80
+ end
81
+
82
+ private
83
+ def log_request_details
84
+ request . route_uri_pattern
85
+ end
86
+ end
87
+
88
+ class WithoutRouterTest < ActionController ::TestCase
89
+ tests WithoutRouterController
90
+
91
+ def test_request_route_uri_pattern_in_after_action_callback
92
+ assert_nothing_raised do
93
+ get :index
94
+ end
95
+ end
96
+ end
97
+
75
98
class ControllerClassTests < ActiveSupport ::TestCase
76
99
def test_controller_path
77
100
assert_equal "empty" , EmptyController . controller_path
You can’t perform that action at this time.
0 commit comments