File tree Expand file tree Collapse file tree 4 files changed +17
-47
lines changed
lib/action_dispatch/routing Expand file tree Collapse file tree 4 files changed +17
-47
lines changed Original file line number Diff line number Diff line change 166
166
167
167
*Jeremy Green*
168
168
169
+ * A route pointing to a non-existing controller now returns a 500 instead of a 404.
170
+
171
+ A controller not existing isn' t a routing error that should result
172
+ in a 404 , but a programming error that should result in a 500 and
173
+ be reported.
174
+
175
+ Until recently, this was hard to untangle because of the support
176
+ for dynamic ` :controller` segment in routes, but since this is
177
+ deprecated and will be removed in Rails 8.1 , we can now easily
178
+ not consider missing controllers as routing errors.
179
+
180
+ * Jean Boussier *
181
+
169
182
* Add ` check_collisions` option to ` ActionDispatch::Session::CacheStore` .
170
183
171
184
Newly generated session ids use 128 bits of randomness, which is more than
Original file line number Diff line number Diff line change @@ -59,8 +59,6 @@ def serve(req)
59
59
private
60
60
def controller ( req )
61
61
req . controller_class
62
- rescue NameError => e
63
- raise ActionController ::RoutingError , e . message , e . backtrace
64
62
end
65
63
66
64
def dispatch ( controller , action , req , res )
Original file line number Diff line number Diff line change @@ -1283,10 +1283,12 @@ def test_route_constraints_with_options_method_condition_is_valid
1283
1283
1284
1284
def test_route_error_with_missing_controller
1285
1285
set . draw do
1286
- get "/people" => "missing #index"
1286
+ get "/people" => "does_not_exists #index"
1287
1287
end
1288
1288
1289
- assert_raises ( ActionController ::RoutingError ) { request_path_params "/people" }
1289
+ assert_raises ( ActionDispatch ::MissingController , match : "uninitialized constant DoesNotExistsController" ) do
1290
+ request_path_params "/people"
1291
+ end
1290
1292
end
1291
1293
1292
1294
def test_recognize_with_encoded_id_and_regex
Original file line number Diff line number Diff line change @@ -4998,49 +4998,6 @@ def test_positional_args_with_format_false
4998
4998
end
4999
4999
end
5000
5000
5001
- class TestErrorsInController < ActionDispatch ::IntegrationTest
5002
- class ::PostsController < ActionController ::Base
5003
- def foo
5004
- nil . i_do_not_exist
5005
- end
5006
-
5007
- def bar
5008
- NonExistingClass . new
5009
- end
5010
- end
5011
-
5012
- Routes = ActionDispatch ::Routing ::RouteSet . new
5013
- Routes . draw do
5014
- ActionDispatch . deprecator . silence do
5015
- get "/:controller(/:action)"
5016
- end
5017
- end
5018
-
5019
- APP = build_app Routes
5020
-
5021
- def app
5022
- APP
5023
- end
5024
-
5025
- def test_legit_no_method_errors_are_not_caught
5026
- get "/posts/foo"
5027
- assert_equal 500 , response . status
5028
- end
5029
-
5030
- def test_legit_name_errors_are_not_caught
5031
- get "/posts/bar"
5032
- assert_equal 500 , response . status
5033
- end
5034
-
5035
- def test_legit_routing_not_found_responses
5036
- get "/posts/baz"
5037
- assert_equal 404 , response . status
5038
-
5039
- get "/i_do_not_exist"
5040
- assert_equal 404 , response . status
5041
- end
5042
- end
5043
-
5044
5001
class TestPartialDynamicPathSegments < ActionDispatch ::IntegrationTest
5045
5002
Routes = ActionDispatch ::Routing ::RouteSet . new
5046
5003
Routes . draw do
You can’t perform that action at this time.
0 commit comments