2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-06-21 22:28:11 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'User visits the notifications tab', :js do
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project) }
|
2017-06-21 22:28:11 -04:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
2018-07-11 10:36:08 -04:00
|
|
|
project.add_maintainer(user)
|
2017-06-21 22:28:11 -04:00
|
|
|
sign_in(user)
|
|
|
|
visit(profile_notifications_path)
|
|
|
|
end
|
|
|
|
|
2021-05-14 17:10:41 -04:00
|
|
|
it 'turns on the receive product marketing emails setting' do
|
|
|
|
expect(page).to have_content('Notifications')
|
|
|
|
|
|
|
|
expect do
|
|
|
|
check 'Receive product marketing emails'
|
|
|
|
end.to change { user.reload.email_opted_in }.to(true)
|
|
|
|
end
|
|
|
|
|
2017-06-21 22:28:11 -04:00
|
|
|
it 'changes the project notifications setting' do
|
|
|
|
expect(page).to have_content('Notifications')
|
|
|
|
|
2021-03-11 04:09:36 -05:00
|
|
|
first('[data-testid="notification-dropdown"]').click
|
2021-03-01 04:11:01 -05:00
|
|
|
click_button('On mention')
|
2017-06-21 22:28:11 -04:00
|
|
|
|
2021-03-11 04:09:36 -05:00
|
|
|
expect(page).to have_selector('[data-testid="notification-dropdown"]', text: 'On mention')
|
2017-06-21 22:28:11 -04:00
|
|
|
end
|
2019-08-17 01:56:48 -04:00
|
|
|
|
|
|
|
context 'when project emails are disabled' do
|
|
|
|
let(:project) { create(:project, emails_disabled: true) }
|
|
|
|
|
|
|
|
it 'notification button is disabled' do
|
2021-03-11 04:09:36 -05:00
|
|
|
expect(page).to have_selector('[data-testid="notification-dropdown"] .disabled')
|
2019-08-17 01:56:48 -04:00
|
|
|
end
|
|
|
|
end
|
2017-06-21 22:28:11 -04:00
|
|
|
end
|