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 ...@@ -73,5 +73,9 @@ module API
mount ::API::Triggers mount ::API::Triggers
mount ::API::Users mount ::API::Users
mount ::API::Variables mount ::API::Variables
route :any, '*path' do
error!('400 Bad Request', 400)
end
end end
end end
...@@ -90,9 +90,9 @@ describe API::API, api: true do ...@@ -90,9 +90,9 @@ describe API::API, api: true do
expect(json_response['message']).to eq('404 Not found') expect(json_response['message']).to eq('404 Not found')
end end
it "returns a 404 if invalid ID" do it "returns a 400 if invalid ID" do
get api("/users/1ASDF", user) get api("/users/1ASDF", user)
expect(response).to have_http_status(404) expect(response).to have_http_status(400)
end end
end end
......
...@@ -266,7 +266,9 @@ describe "Groups", "routing" do ...@@ -266,7 +266,9 @@ describe "Groups", "routing" do
end end
it "also display group#show on the short path" do 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
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