mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
When a route references a missing controller, raise ActionController::RoutingError with a clearer message
This commit is contained in:
parent
5902391567
commit
dde5b8737b
2 changed files with 17 additions and 3 deletions
|
@ -556,9 +556,13 @@ module ActionDispatch
|
||||||
dispatcher = dispatcher.app
|
dispatcher = dispatcher.app
|
||||||
end
|
end
|
||||||
|
|
||||||
if dispatcher.is_a?(Dispatcher) && dispatcher.controller(params, false)
|
if dispatcher.is_a?(Dispatcher)
|
||||||
dispatcher.prepare_params!(params)
|
if dispatcher.controller(params, false)
|
||||||
return params
|
dispatcher.prepare_params!(params)
|
||||||
|
return params
|
||||||
|
else
|
||||||
|
raise ActionController::RoutingError, "A route matches #{path.inspect}, but references missing controller: #{params[:controller].camelize}Controller"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -902,6 +902,16 @@ class RouteSetTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_route_error_with_missing_controller
|
||||||
|
set.draw do
|
||||||
|
get "/people" => "missing#index"
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_raise(ActionController::RoutingError) {
|
||||||
|
set.recognize_path("/people", :method => :get)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
def test_recognize_with_encoded_id_and_regex
|
def test_recognize_with_encoded_id_and_regex
|
||||||
set.draw do
|
set.draw do
|
||||||
match 'page/:id' => 'pages#show', :id => /[a-zA-Z0-9\+]+/
|
match 'page/:id' => 'pages#show', :id => /[a-zA-Z0-9\+]+/
|
||||||
|
|
Loading…
Reference in a new issue