Improve slow tests in ./spec/requests/api/deployments_spec.rb:192
Summary
The total running time of ./spec/requests/api/deployments_spec.rb:192 is 314.11 seconds and it executes 168 queries. It is likely this can be improved.
The spec tries to render a validation error with deployment
, but deployment
is not initialized until a few lines later. Instead we want to render the error with environment
, since in the previous line we check whether environment.persisted?
, and the spec should fail when environment
name is invalid.
Right now the spec passes because it will time out after 5 minutes (hence the 300+ second runtime), with this fix the spec will run in roughly 0.516916 seconds, shaving more than 5 minutes of the test suite
Description
This issue was generated from the
rspec profiling project
which profiles rspec tests in pipelines run against the default branch on
gitlab-org/gitlab
.