Commit 06638bf5 authored by Sean Arnold's avatar Sean Arnold

Fix docs, add license check for update

parent cfcd67b8
......@@ -40,7 +40,6 @@ Example response:
}
```
## List metric images
```plaintext
......
......@@ -80,6 +80,8 @@ module API
authorize!(:update_alert_management_metric_image, alert)
render_api_error!('Not allowed!', 400) unless alert.metric_images_available?
metric_image = alert.metric_images.find_by_id(params[:metric_image_id])
render_api_error!('Metric image not found', 404) unless metric_image
......
......@@ -299,25 +299,44 @@ RSpec.describe API::AlertManagementAlerts do
project.add_developer(user)
end
context 'metric image not found' do
subject { put api("/projects/#{project.id}/alert_management_alerts/#{alert.iid}/metric_images/#{non_existing_record_id}", user) }
context 'feature is enabled' do
before do
stub_licensed_features(alert_metric_upload: true)
end
it 'returns an error' do
subject
context 'metric image not found' do
subject { put api("/projects/#{project.id}/alert_management_alerts/#{alert.iid}/metric_images/#{non_existing_record_id}", user) }
it 'returns an error' do
subject
expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('Metric image not found')
expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('Metric image not found')
end
end
context 'metric image cannot be updated' do
let(:params) { { url_text: 'something_long' * 100 } }
it 'returns an error' do
subject
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq('Metric image could not be updated')
end
end
end
context 'metric image cannot be updated' do
let(:params) { { url_text: 'something_long' * 100 } }
context 'feature not enabled' do
before do
stub_licensed_features(alert_metric_upload: false)
end
it 'returns an error' do
subject
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq('Metric image could not be updated')
expect(json_response['message']).to eq('Not allowed!')
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