mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #2549 from trek/RoutingErrorForMissingControllers
When a route references a missing controller, raise ActionController::RoutingError with clearer message
This commit is contained in:
commit
513a0525c2
2 changed files with 17 additions and 3 deletions
|
@ -663,9 +663,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
|
||||||
|
|
||||||
|
|
|
@ -1037,6 +1037,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
|
||||||
get 'page/:id' => 'pages#show', :id => /[a-zA-Z0-9\+]+/
|
get 'page/:id' => 'pages#show', :id => /[a-zA-Z0-9\+]+/
|
||||||
|
|
Loading…
Reference in a new issue