2020-04-21 11:21:10 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Projects::AlertManagementHelper do
|
|
|
|
include Gitlab::Routing.url_helpers
|
|
|
|
|
2020-04-27 14:09:41 -04:00
|
|
|
let_it_be(:project, reload: true) { create(:project) }
|
|
|
|
let_it_be(:current_user) { create(:user) }
|
2020-05-06 11:09:42 -04:00
|
|
|
let_it_be(:project_path) { project.full_path }
|
2020-04-21 11:21:10 -04:00
|
|
|
|
|
|
|
describe '#alert_management_data' do
|
2020-05-07 20:09:56 -04:00
|
|
|
let(:user_can_enable_alert_management) { true }
|
|
|
|
let(:setting_path) { edit_project_service_path(project, AlertsService) }
|
2020-04-21 11:21:10 -04:00
|
|
|
|
2020-04-27 14:09:41 -04:00
|
|
|
before do
|
|
|
|
allow(helper)
|
|
|
|
.to receive(:can?)
|
2020-05-07 20:09:56 -04:00
|
|
|
.with(current_user, :admin_project, project)
|
2020-04-27 14:09:41 -04:00
|
|
|
.and_return(user_can_enable_alert_management)
|
|
|
|
end
|
|
|
|
|
2020-04-21 11:21:10 -04:00
|
|
|
context 'without alert_managements_setting' do
|
2020-05-06 11:09:42 -04:00
|
|
|
it 'returns index page configuration' do
|
2020-05-07 20:09:56 -04:00
|
|
|
expect(helper.alert_management_data(current_user, project)).to match(
|
2020-04-30 08:09:45 -04:00
|
|
|
'project-path' => project_path,
|
2020-04-21 11:21:10 -04:00
|
|
|
'enable-alert-management-path' => setting_path,
|
2020-05-07 20:09:56 -04:00
|
|
|
'empty-alert-svg-path' => match_asset_path('/assets/illustrations/alert-management-empty-state.svg'),
|
|
|
|
'user-can-enable-alert-management' => 'true',
|
2020-04-27 14:09:41 -04:00
|
|
|
'alert-management-enabled' => 'true'
|
2020-04-21 11:21:10 -04:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
2020-05-07 20:09:56 -04:00
|
|
|
|
|
|
|
context 'when user does not have requisite enablement permissions' do
|
|
|
|
let(:user_can_enable_alert_management) { false }
|
|
|
|
|
|
|
|
it 'shows error tracking enablement as disabled' do
|
|
|
|
expect(helper.alert_management_data(current_user, project)).to include(
|
|
|
|
'user-can-enable-alert-management' => 'false'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
2020-04-21 11:21:10 -04:00
|
|
|
end
|
2020-05-06 11:09:42 -04:00
|
|
|
|
|
|
|
describe '#alert_management_detail_data' do
|
|
|
|
let(:alert_id) { 1 }
|
|
|
|
|
|
|
|
it 'returns detail page configuration' do
|
2020-05-07 20:09:56 -04:00
|
|
|
expect(helper.alert_management_detail_data(project_path, alert_id)).to eq(
|
2020-05-06 11:09:42 -04:00
|
|
|
'alert-id' => alert_id,
|
|
|
|
'project-path' => project_path
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
2020-04-21 11:21:10 -04:00
|
|
|
end
|