Commit 5e0beca6 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'pl-test-invalid-creation' into 'master'

Test that alert's environment is verified

See merge request gitlab-org/gitlab-ee!7360
parents 251d14c2 b01efeae
...@@ -30,7 +30,7 @@ module Projects ...@@ -30,7 +30,7 @@ module Projects
def create def create
@alert = project.prometheus_alerts.create(alerts_params) @alert = project.prometheus_alerts.create(alerts_params)
if @alert if @alert.persisted?
schedule_prometheus_update! schedule_prometheus_update!
render json: serialize_as_json(@alert) render json: serialize_as_json(@alert)
......
---
title: Return proper status code when creation of an alert fails
merge_request: 7360
author: Peter Leitzen
type: fixed
...@@ -146,6 +146,21 @@ describe Projects::Prometheus::AlertsController do ...@@ -146,6 +146,21 @@ describe Projects::Prometheus::AlertsController do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(200)
expect(JSON.parse(response.body)).to include(alert_params) expect(JSON.parse(response.body)).to include(alert_params)
end end
context 'with a project non-specific environment' do
let(:environment) { create(:environment) }
it 'returns 204 status' do
post :create, project_params(
operator: ">",
threshold: "1",
environment_id: environment.id,
prometheus_metric_id: metric.id
)
expect(response).to have_gitlab_http_status(:no_content)
end
end
end end
describe 'POST #update' do describe 'POST #update' do
......
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