Commit d6cfc004 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Catch any undefined API routing and return 400 Bad Request

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 68ab7047
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment