Skip to content
Snippets Groups Projects
Unverified Commit 2e904d5f authored by Ahmed Hemdan's avatar Ahmed Hemdan
Browse files

Gracefully handle invalid states when filtering environments

Changelog: fixed
parent 01e5fb65
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -30,6 +30,8 @@ class Environments < ::API::Base
environments = ::Environments::EnvironmentsFinder.new(user_project, current_user, params).execute
 
present paginate(environments), with: Entities::Environment, current_user: current_user
rescue ::Environments::EnvironmentsFinder::InvalidStatesError => exception
bad_request!(exception.message)
end
 
desc 'Creates a new environment' do
Loading
Loading
Loading
Loading
@@ -151,6 +151,13 @@
expect(json_response).to be_an Array
expect(json_response.size).to eq(0)
end
it 'returns a 400 status code with invalid states' do
get api("/projects/#{project.id}/environments?states=test", user)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to include('Requested states are invalid')
end
end
end
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment