Commit d8c3c071 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'pl-fix-show-external-alerts' into 'master'

Show alerts settings only for manual configuration

See merge request gitlab-org/gitlab-ee!9538
parents f74c5aa4 e82cee75
- return unless can?(current_user, :read_prometheus_alerts, @project)
- return unless @service.manual_configuration?
- notify_url = notify_project_prometheus_alerts_url(@project, format: :json)
- authorization_key = @project.alerting_setting.try(:token)
......
---
title: Show alerts settings only for manual configuration
merge_request: 9538
author:
type: fixed
# frozen_string_literal: true
require 'spec_helper'
describe 'Prometheus external alerts', :js do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:alerts_section_selector) { '.js-prometheus-alerts' }
let(:alerts_section) { page.find(alerts_section_selector) }
before do
stub_licensed_features(prometheus_alerts: true)
sign_in(user)
project.add_maintainer(user)
visit_edit_service
end
context 'with manual configuration' do
before do
check('Active')
fill_in('API URL', with: 'http://prometheus.example.com')
click_button('Save changes')
visit_edit_service
end
it 'shows the Alerts section' do
wait_for_requests
expect(alerts_section).to have_content('Alerts')
expect(alerts_section).to have_content('Receive alerts from manually configured Prometheus servers.')
expect(alerts_section).to have_content('URL')
expect(alerts_section).to have_content('Authorization key')
end
end
context 'with no configuration' do
it 'does not show the Alerts section' do
wait_for_requests
expect(page).not_to have_css(alerts_section_selector)
end
end
private
def visit_edit_service
visit(project_settings_integrations_path(project))
click_link('Prometheus')
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