pull/11339/head
Dmitrii 2 years ago
parent 68d073c2cc
commit 0c85cc4287
  1. 2
      app/seeders/admin_user_seeder.rb
  2. 2
      app/seeders/development_data/users_seeder.rb
  3. 2
      app/services/users/set_attributes_service.rb
  4. 22
      frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.html
  5. 10
      frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.ts
  6. 8
      modules/documents/spec/services/notifications/create_from_model_service_document_spec.rb
  7. 3
      spec/features/notifications/reminder_mail_spec.rb
  8. 9
      spec/features/users/notifications/shared_examples.rb
  9. 12
      spec/lib/api/v3/user_preferences/user_preference_representer_parsing_spec.rb
  10. 2
      spec/models/mail_handler_spec.rb
  11. 4
      spec/services/notifications/create_from_model_service_comment_spec.rb
  12. 8
      spec/services/notifications/create_from_model_service_message_spec.rb
  13. 4
      spec/services/notifications/create_from_model_service_news_spec.rb
  14. 8
      spec/services/notifications/create_from_model_service_wiki_spec.rb
  15. 8
      spec/services/notifications/create_from_model_service_work_package_spec.rb
  16. 13
      spec/services/notifications/mail_service_mentioned_integration_spec.rb
  17. 3
      spec/services/notifications/mentioned_journals_shared.rb
  18. 9
      spec/services/user_preferences/update_service_integration_spec.rb
  19. 3
      spec/support/pages/notifications/settings.rb
  20. 8
      spec/workers/mails/shared/watcher_job.rb

@ -55,7 +55,7 @@ class AdminUserSeeder < Seeder
user.language = I18n.locale.to_s
user.status = User.statuses[:active]
user.force_password_change = force_password_change?
user.notification_settings.build(involved: true, mentioned: true, watched: true)
user.notification_settings.build(assignee: true, responsible: true, mentioned: true, watched: true)
end
end

@ -103,7 +103,7 @@ module DevelopmentData
user.status = User.statuses[:active]
user.language = I18n.locale
user.force_password_change = false
user.notification_settings.build(involved: true, mentioned: true, watched: true)
user.notification_settings.build(assignee: true, responsible: true, mentioned: true, watched: true)
end
end

@ -62,7 +62,7 @@ module Users
end
def initialize_notification_settings
model.notification_settings.build(involved: true, mentioned: true, watched: true)
model.notification_settings.build(assignee: true, responsible: true, mentioned: true, watched: true)
end
# rubocop:disable Metrics/AbcSize

@ -30,15 +30,29 @@
</tr>
<tr>
<th class="op-table--cell op-table--cell_soft-heading">
<h5>{{ text.involved_header.title }}</h5>
<p>{{ text.involved_header.description }}</p>
<h5>{{ text.assignee }}</h5>
</th>
<ng-container *ngFor="let item of settings.controls">
<td class="op-table--cell" [formGroup]="item">
<input
type="checkbox"
formControlName="involved"
data-qa-project-notification-type="involved"
formControlName="assignee"
data-qa-project-notification-type="assignee"
[attr.data-qa-project]="item.controls.project.value.title"
/>
</td>
</ng-container>
</tr>
<tr>
<th class="op-table--cell op-table--cell_soft-heading">
<h5>{{ text.responsible }}</h5>
</th>
<ng-container *ngFor="let item of settings.controls">
<td class="op-table--cell" [formGroup]="item">
<input
type="checkbox"
formControlName="responsible"
data-qa-project-notification-type="responsible"
[attr.data-qa-project]="item.controls.project.value.title"
/>
</td>

@ -9,7 +9,6 @@ import { FormArray, FormGroup, FormControl } from '@angular/forms';
import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import idFromLink from 'core-app/features/hal/helpers/id-from-link';
import { UserPreferencesService } from 'core-app/features/user-preferences/state/user-preferences.service';
import { HalSourceLink } from 'core-app/features/hal/resources/hal-resource';
@Component({
@ -30,10 +29,8 @@ export class NotificationSettingsTableComponent {
title: this.I18n.t('js.notifications.settings.reasons.mentioned.title'),
description: this.I18n.t('js.notifications.settings.reasons.mentioned.description'),
},
involved_header: {
title: this.I18n.t('js.notifications.settings.reasons.involved.title'),
description: this.I18n.t('js.notifications.settings.reasons.involved.description'),
},
assignee: this.I18n.t('js.notifications.settings.reasons.assignee'),
responsible: this.I18n.t('js.notifications.settings.reasons.responsible'),
watched_header: this.I18n.t('js.notifications.settings.reasons.watched'),
work_package_commented_header: this.I18n.t('js.notifications.settings.reasons.work_package_commented'),
work_package_created_header: this.I18n.t('js.notifications.settings.reasons.work_package_created'),
@ -55,7 +52,8 @@ export class NotificationSettingsTableComponent {
addProjectSettings(project:HalSourceLink):void {
this.settings.push(new FormGroup({
project: new FormControl(project),
involved: new FormControl(false),
assignee: new FormControl(false),
responsible: new FormControl(false),
workPackageCreated: new FormControl(false),
workPackageProcessed: new FormControl(false),
workPackageScheduled: new FormControl(false),

@ -68,10 +68,10 @@ describe Notifications::CreateFromModelService, 'document', with_settings: { jou
end
end
context 'with the user having registered for involved notifications' do
context 'with the user having registered for assignee and responsible notifications' do
let(:recipient_notification_settings) do
[
build(:notification_setting, **notification_settings_all_false.merge(involved: true))
build(:notification_setting, **notification_settings_all_false.merge(assignee: true, responsible: true))
]
end
@ -116,10 +116,10 @@ describe Notifications::CreateFromModelService, 'document', with_settings: { jou
end
end
context 'with the user having registered for involved notifications' do
context 'with the user having registered for assignee and responsible notifications' do
let(:recipient_notification_settings) do
[
build(:notification_setting, **notification_settings_all_false.merge(involved: true))
build(:notification_setting, **notification_settings_all_false.merge(assignee: true, responsible: true))
]
end

@ -36,7 +36,8 @@ describe "Reminder email sending", type: :feature, js: true do
},
notification_settings: [
build(:notification_setting,
involved: true,
assignee: true,
responsible: true,
watched: true,
mentioned: true,
work_package_commented: true,

@ -15,7 +15,8 @@ shared_examples 'notification settings workflow' do
settings_page.add_project project_alt
# Set settings for project email
settings_page.configure_global involved: true,
settings_page.configure_global assignee: true,
responsible: true,
work_package_commented: true,
work_package_created: true,
work_package_processed: true,
@ -24,7 +25,8 @@ shared_examples 'notification settings workflow' do
# Set settings for project email
settings_page.configure_project project: project,
involved: true,
assignee: true,
responsible: true,
work_package_commented: false,
work_package_created: false,
work_package_processed: false,
@ -39,7 +41,8 @@ shared_examples 'notification settings workflow' do
expect(notification_settings.where(project:).count).to eq 1
project_settings = notification_settings.find_by(project:)
expect(project_settings.involved).to be_truthy
expect(project_settings.assignee).to be_truthy
expect(project_settings.responsible).to be_truthy
expect(project_settings.mentioned).to be_truthy
expect(project_settings.watched).to be_truthy
expect(project_settings.work_package_commented).to be_falsey

@ -43,7 +43,8 @@ describe ::API::V3::UserPreferences::UserPreferenceRepresenter,
{
'notifications' => [
{
'involved' => true,
'assignee' => true,
'responsible' => true,
'_links' => {
'project' => {
'href' => '/api/v3/projects/1'
@ -51,7 +52,8 @@ describe ::API::V3::UserPreferences::UserPreferenceRepresenter,
}
},
{
'involved' => false,
'assignee' => false,
'responsible' => false,
'mentioned' => true,
'_links' => {
'project' => {
@ -69,11 +71,13 @@ describe ::API::V3::UserPreferences::UserPreferenceRepresenter,
in_project, global = subject.notification_settings
expect(in_project[:project_id]).to eq "1"
expect(in_project[:involved]).to be_truthy
expect(in_project[:assignee]).to be_truthy
expect(in_project[:responsible]).to be_truthy
expect(in_project[:mentioned]).to be_nil
expect(global[:project_id]).to be_nil
expect(global[:involved]).to be false
expect(global[:assignee]).to be_falsey
expect(global[:responsible]).to be_falsey
expect(global[:mentioned]).to be true
end
end

@ -1071,7 +1071,7 @@ describe MailHandler, type: :model do
assignee = create(:user,
member_in_project: project,
member_with_permissions: %i(view_work_packages),
notification_settings: [build(:notification_setting, involved: true)])
notification_settings: [build(:notification_setting, assignee: true, responsible: true)])
work_package.update_column(:assigned_to_id, assignee.id)

@ -73,10 +73,10 @@ describe Notifications::CreateFromModelService, 'comment', with_settings: { jour
end
end
context 'with the user having registered for involved notifications' do
context 'with the user having registered for assignee and responsible notifications' do
let(:recipient_notification_settings) do
[
build(:notification_setting, **notification_settings_all_false.merge(involved: true))
build(:notification_setting, **notification_settings_all_false.merge(assignee: true, responsible: true))
]
end

@ -74,10 +74,10 @@ describe Notifications::CreateFromModelService, 'message', with_settings: { jour
end
end
context 'with the user having registered for involved notifications' do
context 'with the user having registered for assignee and responsible notifications' do
let(:recipient_notification_settings) do
[
build(:notification_setting, **notification_settings_all_false.merge(involved: true))
build(:notification_setting, **notification_settings_all_false.merge(assignee: true, responsible: true))
]
end
@ -206,10 +206,10 @@ describe Notifications::CreateFromModelService, 'message', with_settings: { jour
end
end
context 'with the user having registered for involved notifications' do
context 'with the user having registered for assignee and responsible notifications' do
let(:recipient_notification_settings) do
[
build(:notification_setting, **notification_settings_all_false.merge(involved: true))
build(:notification_setting, **notification_settings_all_false.merge(assignee: true, responsible: true))
]
end

@ -66,10 +66,10 @@ describe Notifications::CreateFromModelService, 'news', with_settings: { journal
end
end
context 'with the user having registered for involved notifications' do
context 'with the user having registered for assignee and responsible notifications' do
let(:recipient_notification_settings) do
[
build(:notification_setting, **notification_settings_all_false.merge(involved: true))
build(:notification_setting, **notification_settings_all_false.merge(assignee: true, responsible: true))
]
end

@ -72,10 +72,10 @@ describe Notifications::CreateFromModelService, 'wiki', with_settings: { journal
end
end
context 'with the user having registered for involved notifications' do
context 'with the user having registered for assignee and responsible notifications' do
let(:recipient_notification_settings) do
[
build(:notification_setting, **notification_settings_all_false.merge(involved: true))
build(:notification_setting, **notification_settings_all_false.merge(assignee: true, responsible: true))
]
end
@ -165,10 +165,10 @@ describe Notifications::CreateFromModelService, 'wiki', with_settings: { journal
end
end
context 'with the user having registered for involved notifications' do
context 'with the user having registered for assignee and responsible notifications' do
let(:recipient_notification_settings) do
[
build(:notification_setting, **notification_settings_all_false.merge(involved: true))
build(:notification_setting, **notification_settings_all_false.merge(assignee: true, responsible: true))
]
end

@ -103,7 +103,7 @@ describe Notifications::CreateFromModelService,
let(:user_property) { :assigned_to }
let(:recipient_notification_settings) do
[
build(:notification_setting, **notification_settings_all_false.merge(involved: true))
build(:notification_setting, **notification_settings_all_false.merge(assignee: true, responsible: true))
]
end
@ -147,10 +147,10 @@ describe Notifications::CreateFromModelService,
it_behaves_like 'creates no notification'
end
context 'when assignee has all in app notifications enabled but only involved for mail' do
context 'when assignee has all in app notifications enabled but only assignee for mail' do
let(:recipient_notification_settings) do
[
build(:notification_setting, **notification_settings_all_false.merge(involved: true))
build(:notification_setting, **notification_settings_all_false.merge(assignee: true, responsible: true))
]
end
@ -194,7 +194,7 @@ describe Notifications::CreateFromModelService,
let(:user_property) { :responsible }
let(:recipient_notification_settings) do
[
build(:notification_setting, **notification_settings_all_false.merge(involved: true))
build(:notification_setting, **notification_settings_all_false.merge(assignee: true, responsible: true))
]
end

@ -42,7 +42,8 @@ describe Notifications::MailService, 'Mentioned integration', type: :model do
notification_settings: [
build(:notification_setting,
mentioned: true,
involved: true)
assignee: true,
responsible: true)
],
member_in_project: project,
member_through_role: role
@ -62,7 +63,12 @@ describe Notifications::MailService, 'Mentioned integration', type: :model do
end
def expect_no_assigned_notification
expect(Notification.where(recipient:, resource: work_package, reason: :involved))
expect(Notification.where(recipient:, resource: work_package, reason: :assignee))
.to be_empty
end
def expect_no_responsible_notification
expect(Notification.where(recipient:, resource: work_package, reason: :responsible))
.to be_empty
end
@ -94,9 +100,10 @@ describe Notifications::MailService, 'Mentioned integration', type: :model do
.to have_received(:mentioned)
.once
# No involved notification since the assignee is also mentioned which trumps
# No assignee and responsible notification since the assignee is also mentioned which trumps
# being assignee and a user will only get one notification for a journal.
expect_no_assigned_notification
expect_no_responsible_notification
expect_mentioned_notification
update_assignee!(assignee)

@ -52,7 +52,8 @@ shared_context 'with a mentioned work package being updated again' do
notification_settings: [
build(:notification_setting,
mentioned: true,
involved: true)
assignee: true,
responsible: true)
],
member_in_project: project,
member_through_role: role

@ -60,7 +60,8 @@ describe UserPreferences::UpdateService, 'integration', type: :model do
{
project_id: nil,
watched: false,
involved: true,
assignee: true,
responsible: true,
work_package_commented: false,
work_package_created: true,
work_package_processed: true,
@ -76,7 +77,8 @@ describe UserPreferences::UpdateService, 'integration', type: :model do
expect(default_ian.watched).to be true
expect(default_ian.mentioned).to be true
expect(default_ian.involved).to be true
expect(default_ian.assignee).to be true
expect(default_ian.responsible).to be true
expect(default_ian.work_package_commented).to be true
expect(default_ian.work_package_created).to be true
expect(default_ian.work_package_processed).to be true
@ -87,7 +89,8 @@ describe UserPreferences::UpdateService, 'integration', type: :model do
expect(subject.first.project_id).to be_nil
expect(subject.first.mentioned).to be false
expect(subject.first.watched).to be false
expect(subject.first.involved).to be true
expect(default_ian.assignee).to be true
expect(default_ian.responsible).to be true
expect(subject.first.work_package_commented).to be false
expect(subject.first.work_package_created).to be true
expect(subject.first.work_package_processed).to be true

@ -53,7 +53,8 @@ module Pages
def expect_global_represented(setting)
%i[
involved
assignee
responsible
work_package_commented
work_package_created
work_package_processed

@ -126,25 +126,25 @@ shared_examples "watcher job" do |action|
it_behaves_like 'notifies the watcher' do
let(:notification_settings) do
[build_stubbed(:notification_setting, mentioned: false, involved: false, watched: true)]
[build_stubbed(:notification_setting, mentioned: false, assignee: false, responsible: false, watched: true)]
end
end
it_behaves_like 'notifies the watcher' do
let(:notification_settings) do
[build_stubbed(:notification_setting, mentioned: false, involved: false, watched: true)]
[build_stubbed(:notification_setting, mentioned: false, assignee: false, responsible: false, watched: true)]
end
end
it_behaves_like 'does not notify the watcher' do
let(:notification_settings) do
[build_stubbed(:notification_setting, mentioned: false, involved: true, watched: false)]
[build_stubbed(:notification_setting, mentioned: false, assignee: true, responsible: true, watched: false)]
end
end
it_behaves_like 'does not notify the watcher' do
let(:notification_settings) do
[build_stubbed(:notification_setting, mentioned: true, involved: false, watched: false)]
[build_stubbed(:notification_setting, mentioned: true, assignee: false, responsible: false, watched: false)]
end
end

Loading…
Cancel
Save