Catch any undefined API routing and return 400 Bad Request
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
68ab7047da
commit
d6cfc0042e
3 changed files with 9 additions and 3 deletions
|
@ -73,5 +73,9 @@ module API
|
|||
mount ::API::Triggers
|
||||
mount ::API::Users
|
||||
mount ::API::Variables
|
||||
|
||||
route :any, '*path' do
|
||||
error!('400 Bad Request', 400)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -90,9 +90,9 @@ describe API::API, api: true do
|
|||
expect(json_response['message']).to eq('404 Not found')
|
||||
end
|
||||
|
||||
it "returns a 404 if invalid ID" do
|
||||
it "returns a 400 if invalid ID" do
|
||||
get api("/users/1ASDF", user)
|
||||
expect(response).to have_http_status(404)
|
||||
expect(response).to have_http_status(400)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -266,7 +266,9 @@ describe "Groups", "routing" do
|
|||
end
|
||||
|
||||
it "also display group#show on the short path" do
|
||||
expect(get('/1')).to route_to('namespaces#show', id: '1')
|
||||
allow(Group).to receive(:find_by_path).and_return(true)
|
||||
|
||||
expect(get('/1')).to route_to('groups#show', id: '1')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue