Skip to content

Commit 4a61a90

Browse files
Schwadskipkayhil
andcommitted
Fixes perf improvement breaking ActionController::TestCase
Co-Authored-By: Hartley McGuire <[email protected]>
1 parent 7df1b84 commit 4a61a90

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

actionpack/lib/action_dispatch/http/request.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ def request_method
159159
def route_uri_pattern
160160
unless pattern = get_header("action_dispatch.route_uri_pattern")
161161
route = get_header("action_dispatch.route")
162+
return if route.nil?
162163
pattern = route.path.spec.to_s
163164
set_header("action_dispatch.route_uri_pattern", pattern)
164165
end

actionpack/test/controller/base_test.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,29 @@ def action_missing(action)
7272
end
7373
end
7474

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+
7598
class ControllerClassTests < ActiveSupport::TestCase
7699
def test_controller_path
77100
assert_equal "empty", EmptyController.controller_path

0 commit comments

Comments
 (0)