debian-mirror-gitlab/spec/features/projects/services/user_activates_alerts_spec.rb

75 lines
1.8 KiB
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-06-23 00:09:42 +05:30
RSpec.describe 'User activates Alerts', :js do
2020-03-13 15:44:24 +05:30
let_it_be(:project) { create(:project) }
let_it_be(:user) { create(:user) }
let(:service_name) { 'alerts' }
let(:service_title) { 'Alerts endpoint' }
before do
sign_in(user)
project.add_maintainer(user)
end
context 'when service is deactivated' do
2020-07-28 23:09:34 +05:30
it 'user cannot activate service' do
2020-03-13 15:44:24 +05:30
visit_project_services
expect(page).to have_link(service_title)
click_link(service_title)
2020-07-28 23:09:34 +05:30
expect(page).to have_callout_message
2020-03-13 15:44:24 +05:30
expect(page).not_to have_active_service
2020-07-28 23:09:34 +05:30
expect(page).to have_toggle_active_disabled
2020-03-13 15:44:24 +05:30
end
end
context 'when service is activated' do
2020-07-28 23:09:34 +05:30
let_it_be(:activated_alerts_service) do
create(:alerts_service, :active, project: project)
end
2020-03-13 15:44:24 +05:30
before do
visit_alerts_service
end
2020-07-28 23:09:34 +05:30
it 'user cannot change settings' do
expect(page).to have_callout_message
expect(page).to have_active_service
expect(page).to have_toggle_active_disabled
expect(page).to have_button_reset_key_disabled
2020-03-13 15:44:24 +05:30
end
end
private
def visit_project_services
visit(project_settings_integrations_path(project))
end
def visit_alerts_service
visit(edit_project_service_path(project, service_name))
end
2020-07-28 23:09:34 +05:30
def have_callout_message
within('.gl-alert') do
have_content('You can now manage alert endpoint configuration in the Alerts section on the Operations settings page.')
end
2020-03-13 15:44:24 +05:30
end
2020-07-28 23:09:34 +05:30
def have_active_service
have_selector('.js-service-active-status[data-value="true"]')
2020-03-13 15:44:24 +05:30
end
2020-07-28 23:09:34 +05:30
def have_toggle_active_disabled
have_selector('#activated .project-feature-toggle.is-disabled')
2020-03-13 15:44:24 +05:30
end
2020-07-28 23:09:34 +05:30
def have_button_reset_key_disabled
have_button('Reset key', disabled: true)
2020-03-13 15:44:24 +05:30
end
end