debian-mirror-gitlab/spec/features/projects/show/user_manages_notifications_spec.rb

95 lines
2.5 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2018-10-15 14:42:47 +05:30
require 'spec_helper'
describe 'Projects > Show > User manages notifications', :js do
let(:project) { create(:project, :public, :repository) }
before do
sign_in(project.owner)
end
2019-02-15 15:39:39 +05:30
def click_notifications_button
2019-01-03 12:48:30 +05:30
first('.notifications-btn').click
2019-02-15 15:39:39 +05:30
end
it 'changes the notification setting' do
2020-04-08 14:13:33 +05:30
visit project_path(project)
2019-02-15 15:39:39 +05:30
click_notifications_button
2018-10-15 14:42:47 +05:30
click_link 'On mention'
2019-02-15 15:39:39 +05:30
wait_for_requests
click_notifications_button
expect(find('.update-notification.is-active')).to have_content('On mention')
2019-07-31 22:56:46 +05:30
expect(find('.notifications-icon use')[:'xlink:href']).to end_with('#notifications')
end
it 'changes the notification setting to disabled' do
2020-04-08 14:13:33 +05:30
visit project_path(project)
2019-07-31 22:56:46 +05:30
click_notifications_button
click_link 'Disabled'
wait_for_requests
expect(find('.notifications-icon use')[:'xlink:href']).to end_with('#notifications-off')
2018-10-15 14:42:47 +05:30
end
2018-11-18 11:00:15 +05:30
context 'custom notification settings' do
let(:email_events) do
[
:new_note,
:new_issue,
:reopen_issue,
:close_issue,
:reassign_issue,
:issue_due,
:new_merge_request,
:push_to_merge_request,
:reopen_merge_request,
:close_merge_request,
:reassign_merge_request,
:merge_merge_request,
:failed_pipeline,
2020-04-08 14:13:33 +05:30
:fixed_pipeline,
2018-11-18 11:00:15 +05:30
:success_pipeline
]
end
it 'shows notification settings checkbox' do
2020-04-08 14:13:33 +05:30
visit project_path(project)
2019-02-15 15:39:39 +05:30
click_notifications_button
2018-11-18 11:00:15 +05:30
page.find('a[data-notification-level="custom"]').click
page.within('.custom-notifications-form') do
email_events.each do |event_name|
expect(page).to have_selector("input[name='notification_setting[#{event_name}]']")
end
end
end
2020-04-08 14:13:33 +05:30
context 'when ci_pipeline_fixed_notifications is disabled' do
before do
stub_feature_flags(ci_pipeline_fixed_notifications: false)
end
it 'hides fixed_pipeline checkbox' do
visit project_path(project)
click_notifications_button
page.find('a[data-notification-level="custom"]').click
expect(page).not_to have_selector("input[name='notification_setting[fixed_pipeline]']")
end
end
2018-11-18 11:00:15 +05:30
end
2019-10-12 21:52:04 +05:30
context 'when project emails are disabled' do
let(:project) { create(:project, :public, :repository, emails_disabled: true) }
it 'is disabled' do
2020-04-08 14:13:33 +05:30
visit project_path(project)
2019-10-12 21:52:04 +05:30
expect(page).to have_selector('.notifications-btn.disabled', visible: true)
end
end
2018-10-15 14:42:47 +05:30
end