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-04-21 11:21:10 -04:00
|
|
|
|
|
|
|
describe '#alert_management_data' do
|
2020-04-27 14:09:41 -04:00
|
|
|
let(:user_can_enable_alert_management) { false }
|
2020-04-21 11:21:10 -04:00
|
|
|
let(:setting_path) { project_settings_operations_path(project) }
|
2020-04-30 08:09:45 -04:00
|
|
|
let(:project_path) { project.full_path }
|
2020-04-21 11:21:10 -04:00
|
|
|
|
2020-04-27 14:09:41 -04:00
|
|
|
before do
|
|
|
|
allow(helper)
|
|
|
|
.to receive(:can?)
|
|
|
|
.with(current_user, :admin_operations, project)
|
|
|
|
.and_return(user_can_enable_alert_management)
|
|
|
|
end
|
|
|
|
|
2020-04-21 11:21:10 -04:00
|
|
|
context 'without alert_managements_setting' do
|
|
|
|
it 'returns frontend configuration' do
|
2020-04-27 14:09:41 -04:00
|
|
|
expect(alert_management_data(current_user, project)).to eq(
|
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-04-30 08:09:45 -04:00
|
|
|
'empty-alert-svg-path' => '/images/illustrations/alert-management-empty-state.svg',
|
2020-04-27 14:09:41 -04:00
|
|
|
'user-can-enable-alert-management' => 'false',
|
|
|
|
'alert-management-enabled' => 'true'
|
2020-04-21 11:21:10 -04:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|