Commit 9412b5ee authored by gaga5lala's avatar gaga5lala

FIX: handle argument error in api layer

parent dd778448
......@@ -11,6 +11,10 @@ module API
'issues' => ->(iid) { find_project_issue(iid) }
}.freeze
rescue_from ArgumentError do |e|
render_api_error!(e.message, 400)
end
params do
requires :id, type: String, desc: 'The ID of a project'
end
......
......@@ -34,6 +34,13 @@ RSpec.describe API::Todos do
end
context 'when authenticated' do
context 'when invalid params' do
it "returns argument error" do
get api('/todos', john_doe), params: { type: 'InvalidType' }
expect(response).to have_gitlab_http_status(:bad_request)
end
end
it 'returns an array of pending todos for current user' do
get api('/todos', john_doe)
......
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