2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
RSpec.describe 'User visits the notifications tab', :js, feature_category: :user_profile do
|
2017-09-10 17:25:29 +05:30
|
|
|
let(:project) { create(:project) }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
2018-11-18 11:00:15 +05:30
|
|
|
project.add_maintainer(user)
|
2017-09-10 17:25:29 +05:30
|
|
|
sign_in(user)
|
|
|
|
visit(profile_notifications_path)
|
|
|
|
end
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
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-09-10 17:25:29 +05:30
|
|
|
it 'changes the project notifications setting' do
|
|
|
|
expect(page).to have_content('Notifications')
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
first('[data-testid="notification-dropdown"]').click
|
|
|
|
click_button('On mention')
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
expect(page).to have_selector('[data-testid="notification-dropdown"]', text: 'On mention')
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
2019-10-12 21:52:04 +05:30
|
|
|
|
|
|
|
context 'when project emails are disabled' do
|
|
|
|
let(:project) { create(:project, emails_disabled: true) }
|
|
|
|
|
|
|
|
it 'notification button is disabled' do
|
2021-04-17 20:07:23 +05:30
|
|
|
expect(page).to have_selector('[data-testid="notification-dropdown"] .disabled')
|
2019-10-12 21:52:04 +05:30
|
|
|
end
|
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|