OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#44414] Add the Enterprise Edition guard on date alerts settings
Dombi Attilad349c30d7e0f
diff --git a/app/contracts/concerns/requires_enterprise_guard.rb b/app/contracts/concerns/requires_enterprise_guard.rbindex 653c812e5c7..9e294c1e92a 100644--- a/app/contracts/concerns/requires_enterprise_guard.rb+++ b/app/contracts/concerns/requires_enterprise_guard.rb@@ -31,14 +31,16 @@ module RequiresEnterpriseGuardincluded doclass_attribute :enterprise_action- validate :has_enterprise+ class_attribute :enterprise_condition+ # Validate when no enterprise_condition is set, or when it evaluates to true+ validate :has_enterprise, if: -> { enterprise_condition.nil? || instance_exec(&enterprise_condition) }endmodule_functiondef has_enterpriseunless EnterpriseToken.allows_to?(enterprise_action)- errors.add :base, :error_enterprise_only+ errors.add :base, :error_enterprise_only, action: enterprise_action.to_s.titleizeendendenddiff --git a/app/contracts/user_preferences/params_contract.rb b/app/contracts/user_preferences/params_contract.rbindex 00e89295d7e..a829ea34e47 100644--- a/app/contracts/user_preferences/params_contract.rb+++ b/app/contracts/user_preferences/params_contract.rb@@ -28,6 +28,10 @@module UserPreferencesclass ParamsContract < ::ParamsContract+ include RequiresEnterpriseGuard+ self.enterprise_action = :date_alerts+ self.enterprise_condition = ->(*) { date_alerts_set? }+DATE_ALERT_DURATIONS = [nil, 0, 1, 3, 7].freezeDATE_ALERT_OVERDUE_DURATIONS = [nil, 1, 3, 7].freeze@@ -35,9 +39,7 @@ module UserPreferencesif: -> { notifications.present? }validate :global_email_alerts,if: -> { notifications.present? }- validate :global_date_alerts,- if: -> { notifications.present? }- validate :project_date_alerts,+ validate :date_alerts,if: -> { notifications.present? }protected@@ -54,24 +56,16 @@ module UserPreferencesendend- def global_date_alerts- if any_of_date_fields_fail_validation?(global_notifications)- errors.add :notification_settings, :wrong_date- end- end-- def project_date_alerts- if any_of_date_fields_fail_validation?(project_notifications)+ def date_alerts+ if notifications.any?(method(:date_fields_fail_validation?))errors.add :notification_settings, :wrong_dateendend- def any_of_date_fields_fail_validation?(notifications_type)- notifications_type.any? do |setting|- setting.slice(:start_date, :due_date).detect do |_, date|- DATE_ALERT_DURATIONS.exclude?(date)- end || DATE_ALERT_OVERDUE_DURATIONS.exclude?(setting[:overdue])- end+ def date_fields_fail_validation?(setting)+ DATE_ALERT_DURATIONS.exclude?(setting[:start_date]) ||+ DATE_ALERT_DURATIONS.exclude?(setting[:due_date]) ||+ DATE_ALERT_OVERDUE_DURATIONS.exclude?(setting[:overdue])end##@@ -82,6 +76,12 @@ module UserPreferencesendend+ ##+ # Check if the given notification hash has date alert related settings set+ def date_alerts_set?+ (NotificationSetting.date_alert_settings & notifications.flat_map(&:keys)).any?+ end+def global_notificationsnotifications.select { |notification| notification[:project_id].nil? }end@@ -91,7 +91,7 @@ module UserPreferencesenddef notifications- params[:notification_settings]+ params[:notification_settings] || []endendenddiff --git a/app/models/notification_setting.rb b/app/models/notification_setting.rbindex 4dc8e5614f3..81b04adcdcf 100644--- a/app/models/notification_setting.rb+++ b/app/models/notification_setting.rb@@ -31,12 +31,12 @@ class NotificationSetting < ApplicationRecordWORK_PACKAGE_PROCESSED,WORK_PACKAGE_PRIORITIZED,WORK_PACKAGE_SCHEDULED,- *duration_settings,+ *date_alert_settings,*email_settings]end- def self.duration_settings+ def self.date_alert_settings[START_DATE,DUE_DATE,diff --git a/app/services/authorization/enterprise_service.rb b/app/services/authorization/enterprise_service.rbindex 7112af57809..0e0f0b2a0d4 100644--- a/app/services/authorization/enterprise_service.rb+++ b/app/services/authorization/enterprise_service.rb@@ -46,6 +46,7 @@ class Authorization::EnterpriseServicegrid_widget_wp_graphplaceholder_usersteam_planner_view+ date_alerts).freezedef initialize(token)diff --git a/config/locales/en.yml b/config/locales/en.ymlindex 49ed2aed4a8..2ba4c47a1b5 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -645,7 +645,7 @@ en:confirmation: "doesn't match %{attribute}."could_not_be_copied: "%{dependency} could not be (fully) copied."does_not_exist: "does not exist."- error_enterprise_only: "is only available in the OpenProject Enterprise Edition"+ error_enterprise_only: "%{action} is only available in the OpenProject Enterprise Edition"error_unauthorized: "may not be accessed."error_readonly: "was attempted to be written but is not writable."email: "is not a valid email address."diff --git a/config/locales/js-en.yml b/config/locales/js-en.ymlindex 5e8dbe1b54f..6024772f465 100644--- a/config/locales/js-en.yml+++ b/config/locales/js-en.yml@@ -661,6 +661,7 @@ en:date_alerts:title: 'Date alerts'description: 'Automatic notifications when important dates are approaching for open work packages you are involved in (assignee, accountable or watcher)'+ teaser_text: 'With date alerts, you will be notified of upcoming start or finish dates so that you never miss or forget an important deadline.'start_date: Start Datedue_date: Finish Dateoverdue: When Overduediff --git a/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.html b/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.htmlindex 7c946d0ad90..945496af1ca 100644--- a/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.html+++ b/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.html@@ -55,102 +55,113 @@<h5>{{ text.dateAlerts.title }}</h5><p>{{ text.dateAlerts.description }}</p>- <div- class="op-reminder-settings-date-alerts--row"- formGroupName="startDate"- >- <input- type="checkbox"- formControlName="active"- class="op-reminder-settings-date-alerts--active"- attr.data-qa-selector="op-settings-start-date"- id="op-settings-start-date"- />- <label- class="op-reminder-settings-date-alerts--label"- [textContent]="text.startDate"- for="op-settings-start-date"- ></label>- <select- formControlName="time"- class="op-reminder-settings-date-alerts--time form--select -narrow"- attr.id="op-reminder-settings-date-alerts"- id="op-reminder-settings-start-date-alerts"- required="true"- *ngIf="dateAlertsStatuses.startDate"+ <div *ngIf="!eeShowBanners">+ <div+ class="op-reminder-settings-date-alerts--row"+ formGroupName="startDate">- <option- *ngFor="let availableTime of availableTimes"- [value]="availableTime.value"+ <input+ type="checkbox"+ formControlName="active"+ class="op-reminder-settings-date-alerts--active"+ attr.data-qa-selector="op-settings-start-date"+ id="op-settings-start-date"+ />+ <label+ class="op-reminder-settings-date-alerts--label"+ [textContent]="text.startDate"+ for="op-settings-start-date"+ ></label>+ <select+ formControlName="time"+ class="op-reminder-settings-date-alerts--time form--select -narrow"+ attr.id="op-reminder-settings-date-alerts"+ id="op-reminder-settings-start-date-alerts"+ required="true"+ *ngIf="dateAlertsStatuses.startDate">- {{availableTime.title}}- </option>- </select>- </div>-- <div- class="op-reminder-settings-date-alerts--row"- formGroupName="dueDate"- >- <input- type="checkbox"- formControlName="active"- class="op-reminder-settings-date-alerts--active"- attr.data-qa-selector="op-settings-due-date"- id="op-settings-due-date"- />- <label- class="op-reminder-settings-date-alerts--label"- [textContent]="text.dueDate"- for="op-settings-due-date"- ></label>- <select- formControlName="time"- class="op-reminder-settings-date-alerts--time form--select -narrow"- attr.id="op-reminder-settings-date-alerts"- id="op-reminder-settings-due-date-alerts"- required="true"- *ngIf="dateAlertsStatuses.dueDate"+ <option+ *ngFor="let availableTime of availableTimes"+ [value]="availableTime.value"+ >+ {{availableTime.title}}+ </option>+ </select>+ </div>++ <div+ class="op-reminder-settings-date-alerts--row"+ formGroupName="dueDate">- <option- *ngFor="let availableTime of availableTimes"- [value]="availableTime.value">- {{availableTime.title}}- </option>- </select>- </div>-- <div- class="op-reminder-settings-date-alerts--row"- formGroupName="overdue"- >- <input- formControlName="active"- type="checkbox"- class="op-reminder-settings-date-alerts--active"- attr.data-qa-selector="op-settings-overdue-date"- id="op-settings-overdue-date">- <label- class="op-reminder-settings-date-alerts--label"- [textContent]="text.overdue"- for="op-settings-overdue-date"- ></label>- <select- formControlName="time"- class="op-reminder-settings-date-alerts--time form--select -narrow"- attr.id="op-reminder-settings-date-alerts"- id="op-reminder-settings-overdue-date-alerts"- required="true"- *ngIf="dateAlertsStatuses.overdue"+ <input+ type="checkbox"+ formControlName="active"+ class="op-reminder-settings-date-alerts--active"+ attr.data-qa-selector="op-settings-due-date"+ id="op-settings-due-date"+ />+ <label+ class="op-reminder-settings-date-alerts--label"+ [textContent]="text.dueDate"+ for="op-settings-due-date"+ ></label>+ <select+ formControlName="time"+ class="op-reminder-settings-date-alerts--time form--select -narrow"+ attr.id="op-reminder-settings-date-alerts"+ id="op-reminder-settings-due-date-alerts"+ required="true"+ *ngIf="dateAlertsStatuses.dueDate"+ >+ <option+ *ngFor="let availableTime of availableTimes"+ [value]="availableTime.value">+ {{availableTime.title}}+ </option>+ </select>+ </div>++ <div+ class="op-reminder-settings-date-alerts--row"+ formGroupName="overdue">- <option- *ngFor="let availableTime of availableTimesOverdue"- [value]="availableTime.value">- {{availableTime.title}}- </option>- </select>+ <input+ formControlName="active"+ type="checkbox"+ class="op-reminder-settings-date-alerts--active"+ attr.data-qa-selector="op-settings-overdue-date"+ id="op-settings-overdue-date">+ <label+ class="op-reminder-settings-date-alerts--label"+ [textContent]="text.overdue"+ for="op-settings-overdue-date"+ ></label>+ <select+ formControlName="time"+ class="op-reminder-settings-date-alerts--time form--select -narrow"+ attr.id="op-reminder-settings-date-alerts"+ id="op-reminder-settings-overdue-date-alerts"+ required="true"+ *ngIf="dateAlertsStatuses.overdue"+ >+ <option+ *ngFor="let availableTime of availableTimesOverdue"+ [value]="availableTime.value">+ {{availableTime.title}}+ </option>+ </select>+ </div></div>+ <op-enterprise-banner+ *ngIf="eeShowBanners"+ [moreInfoLink]="text.more_info_link"+ [collapsible]="true"+ [textMessage]="text.teaser_text"+ opReferrer="notifications#date-alerts"+ class="op-date-alert-ee-banner">+ </op-enterprise-banner>+<h5>{{ text.alsoNotifyFor.title }}</h5><p>{{ text.alsoNotifyFor.description }}</p>diff --git a/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.sass b/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.sassindex 8db7c36c3be..ccb2fa5dda5 100644--- a/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.sass+++ b/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.sass@@ -21,3 +21,6 @@height: 32pxwidth: 128pxpadding: 4px 8px 4px 12px++.op-date-alert-ee-banner+ width: 100%diff --git a/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.ts b/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.tsindex fd3c11d940a..cff515babd5 100644--- a/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.ts+++ b/frontend/src/app/features/user-preferences/notifications-settings/page/notifications-settings-page.component.ts@@ -17,6 +17,8 @@ import { CurrentUserService } from 'core-app/core/current-user/current-user.servimport { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';import { UserPreferencesService } from 'core-app/features/user-preferences/state/user-preferences.service';import { INotificationSetting } from 'core-app/features/user-preferences/state/notification-setting.model';+import { BannersService } from 'core-app/core/enterprise/banners.service';+import { enterpriseDocsUrl } from 'core-app/core/setup/globals/constants.const';import { OVERDUE_REMINDER_AVAILABLE_TIMEFRAMES, REMINDER_AVAILABLE_TIMEFRAMES } from '../overdue-reminder-available-times';export const myNotificationsPageComponentSelector = 'op-notifications-page';@@ -61,6 +63,8 @@ export class NotificationsSettingsPageComponent extends UntilDestroyedMixin implpublic availableTimesOverdue = OVERDUE_REMINDER_AVAILABLE_TIMEFRAMES;+ public eeShowBanners = false;+public form = new FormGroup({assignee: new FormControl(false),responsible: new FormControl(false),@@ -117,6 +121,9 @@ export class NotificationsSettingsPageComponent extends UntilDestroyedMixin implstartDate: this.I18n.t('js.notifications.settings.global.start_date'),dueDate: this.I18n.t('js.notifications.settings.global.due_date'),overdue: this.I18n.t('js.notifications.settings.global.overdue'),+ teaser_text: this.I18n.t('js.notifications.settings.global.date_alerts.teaser_text'),+ upgrade_to_ee_text: this.I18n.t('js.boards.upsale.upgrade'),+ more_info_link: enterpriseDocsUrl.website,};dateAlertsStatuses = {@@ -131,6 +138,7 @@ export class NotificationsSettingsPageComponent extends UntilDestroyedMixin implprivate storeService:UserPreferencesService,private currentUserService:CurrentUserService,private uiRouterGlobals:UIRouterGlobals,+ readonly bannersService:BannersService,) {super();}@@ -138,6 +146,8 @@ export class NotificationsSettingsPageComponent extends UntilDestroyedMixin implngOnInit():void {this.form.disable();this.userId = (this.userId || this.uiRouterGlobals.params.userId) as string;+ this.eeShowBanners = this.bannersService.eeShowBanners;+this.currentUserService.user$diff --git a/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.html b/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.htmlindex 7d673e25d4a..797b61f5515 100644--- a/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.html+++ b/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.html@@ -79,7 +79,7 @@</ng-container></tr>- <tr>+ <tr *ngIf="!eeShowBanners"><th class="op-table--cell op-table--cell_soft-heading"><h5>{{ text.dateAlerts.title }}</h5><p>{{ text.dateAlerts.description }}</p>@@ -89,7 +89,7 @@</ng-container></tr>- <tr>+ <tr *ngIf="!eeShowBanners"><th class="op-table--cell op-table--cell_soft-heading">{{ text.startDate }}</th>@@ -112,7 +112,7 @@</ng-container></tr>- <tr>+ <tr *ngIf="!eeShowBanners"><th class="op-table--cell op-table--cell_soft-heading">{{ text.dueDate }}</th>@@ -135,7 +135,7 @@</ng-container></tr>- <tr>+ <tr *ngIf="!eeShowBanners"><th class="op-table--cell op-table--cell_soft-heading">{{ text.overdue }}</th>diff --git a/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.ts b/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.tsindex 8c066a60de9..cf7189e33f7 100644--- a/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.ts+++ b/frontend/src/app/features/user-preferences/notifications-settings/table/notification-settings-table.component.ts@@ -4,12 +4,14 @@ import {Component,ChangeDetectionStrategy,Input,+ OnInit,} from '@angular/core';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 { HalSourceLink } from 'core-app/features/hal/resources/hal-resource';+import { BannersService } from 'core-app/core/enterprise/banners.service';import { OVERDUE_REMINDER_AVAILABLE_TIMEFRAMES, REMINDER_AVAILABLE_TIMEFRAMES } from '../overdue-reminder-available-times';@Component({@@ -18,11 +20,13 @@ import { OVERDUE_REMINDER_AVAILABLE_TIMEFRAMES, REMINDER_AVAILABLE_TIMEFRAMES }styleUrls: ['./notification-settings-table.component.sass'],changeDetection: ChangeDetectionStrategy.OnPush,})-export class NotificationSettingsTableComponent {+export class NotificationSettingsTableComponent implements OnInit {@Input() userId:string;@Input() settings:FormArray;+ public eeShowBanners = false;+public availableTimes = [{value: null,@@ -75,8 +79,13 @@ export class NotificationSettingsTableComponent {constructor(private I18n:I18nService,private pathHelper:PathHelperService,+ readonly bannersService:BannersService,) {}+ ngOnInit():void {+ this.eeShowBanners = this.bannersService.eeShowBanners;+ }+projectLink(href:string) {return this.pathHelper.projectPath(idFromLink(href));}diff --git a/frontend/src/app/features/user-preferences/state/notification-setting.model.ts b/frontend/src/app/features/user-preferences/state/notification-setting.model.tsindex 89c50b396b0..accbc9a202d 100644--- a/frontend/src/app/features/user-preferences/state/notification-setting.model.ts+++ b/frontend/src/app/features/user-preferences/state/notification-setting.model.ts@@ -19,9 +19,9 @@ export interface INotificationSetting {wikiPageUpdated:boolean;membershipAdded:boolean;membershipUpdated:boolean;- startDate:string|null;- dueDate:string|null;- overdue:string|null;+ startDate?:string|null;+ dueDate?:string|null;+ overdue?:string|null;}export function buildNotificationSetting(project:null|HalSourceLink, params:Partial<INotificationSetting>):INotificationSetting {diff --git a/lib/api/v3/user_preferences/notification_setting_representer.rb b/lib/api/v3/user_preferences/notification_setting_representer.rbindex 5aa77e2177d..740bcb34be8 100644--- a/lib/api/v3/user_preferences/notification_setting_representer.rb+++ b/lib/api/v3/user_preferences/notification_setting_representer.rb@@ -34,8 +34,8 @@ module APIinclude API::Decorators::DatePropertyNotificationSetting.all_settings.each do |setting|- if setting.in?(NotificationSetting.duration_settings)- duration_property setting+ if setting.in?(NotificationSetting.date_alert_settings)+ duration_property setting, if: ->(*) { EnterpriseToken.allows_to?(:date_alerts) }elseproperty settingenddiff --git a/spec/contracts/user_preferences/params_contract_spec.rb b/spec/contracts/user_preferences/params_contract_spec.rbindex a19e3d20584..85e82ee6533 100644--- a/spec/contracts/user_preferences/params_contract_spec.rb+++ b/spec/contracts/user_preferences/params_contract_spec.rb@@ -86,84 +86,114 @@ describe UserPreferences::ParamsContract doit_behaves_like 'contract is valid'end- context 'when project setting with start_date, due_date and overdue set' do- let(:notification_settings) do- [- { project_id: 1234, start_date: 1, due_date: 1, overdue: 1 }- ]+ context 'without enterprise' do+ context 'when global setting with start_date, due_date and overdue set' do+ let(:notification_settings) do+ [+ { start_date: 1, due_date: 1, overdue: 1 }+ ]+ end++ it_behaves_like 'contract is invalid', base: :error_enterprise_only do+ it 'displays the error message containing the feature name' do+ contract.validate+ expect(contract.errors.full_messages)+ .to eq(["Date Alerts is only available in the OpenProject Enterprise Edition"])+ end+ endend- it_behaves_like 'contract is valid'+ context 'when project setting with start_date, due_date and overdue set' do+ let(:notification_settings) do+ [+ { project_id: 1234, start_date: 1, due_date: 1, overdue: 1 }+ ]+ end++ it_behaves_like 'contract is invalid', base: :error_enterprise_only+ endend- context 'when global setting with start_date, due_date and overdue set' do- let(:notification_settings) do- [- { start_date: 1, due_date: 1, overdue: 1 }- ]+ context 'with enterprise', with_ee: %i[date_alerts] do+ context 'when project setting with start_date, due_date and overdue set' do+ let(:notification_settings) do+ [+ { project_id: 1234, start_date: 1, due_date: 1, overdue: 1 }+ ]+ end++ it_behaves_like 'contract is valid'end- it_behaves_like 'contract is valid'- end+ context 'when global setting with start_date, due_date and overdue set' do+ let(:notification_settings) do+ [+ { start_date: 1, due_date: 1, overdue: 1 }+ ]+ end- context 'when project setting with valid start_date, valid due_date and invalid overdue' do- let(:notification_settings) do- [- { project_id: 1234, start_date: 1, due_date: 1, overdue: 0 }- ]+ it_behaves_like 'contract is valid'end- it_behaves_like 'contract is invalid', notification_settings: :wrong_date- end+ context 'when project setting with valid start_date, valid due_date and invalid overdue' do+ let(:notification_settings) do+ [+ { project_id: 1234, start_date: 1, due_date: 1, overdue: 0 }+ ]+ end- context 'when global setting with invalid start_date, valid due_date and valid overdue' do- let(:notification_settings) do- [- { start_date: -1, due_date: 1, overdue: 1 }- ]+ it_behaves_like 'contract is invalid', notification_settings: :wrong_dateend- it_behaves_like 'contract is invalid', notification_settings: :wrong_date- end+ context 'when global setting with invalid start_date, valid due_date and valid overdue' do+ let(:notification_settings) do+ [+ { start_date: -1, due_date: 1, overdue: 1 }+ ]+ end- context 'when project setting with start_date, due_date and overdue missing' do- let(:notification_settings) do- [- { project_id: 1234, start_date: 1, due_date: 1 }- ]+ it_behaves_like 'contract is invalid', notification_settings: :wrong_dateend- it_behaves_like 'contract is valid'- end+ context 'when project setting with start_date, due_date and overdue missing' do+ let(:notification_settings) do+ [+ { project_id: 1234, start_date: 1, due_date: 1 }+ ]+ end- context 'when global setting with start_date, due_date and overdue missing' do- let(:notification_settings) do- [- { start_date: 1, due_date: 1 }- ]+ it_behaves_like 'contract is valid'end- it_behaves_like 'contract is valid'- end+ context 'when global setting with start_date, due_date and overdue missing' do+ let(:notification_settings) do+ [+ { start_date: 1, due_date: 1 }+ ]+ end- context 'when project setting with valid start_date, invalid due_date and overdue missing' do- let(:notification_settings) do- [- { project_id: 1234, start_date: 1, due_date: 24 }- ]+ it_behaves_like 'contract is valid'end- it_behaves_like 'contract is invalid', notification_settings: :wrong_date- end+ context 'when project setting with valid start_date, invalid due_date and overdue missing' do+ let(:notification_settings) do+ [+ { project_id: 1234, start_date: 1, due_date: 24 }+ ]+ end- context 'when global setting with invalid start_date, valid due_date and overdue missing' do- let(:notification_settings) do- [- { start_date: 24, due_date: 1 }- ]+ it_behaves_like 'contract is invalid', notification_settings: :wrong_dateend- it_behaves_like 'contract is invalid', notification_settings: :wrong_date+ context 'when global setting with invalid start_date, valid due_date and overdue missing' do+ let(:notification_settings) do+ [+ { start_date: 24, due_date: 1 }+ ]+ end++ it_behaves_like 'contract is invalid', notification_settings: :wrong_date+ endendcontext 'when notification_settings empty' dodiff --git a/spec/controllers/placeholder_users_controller_spec.rb b/spec/controllers/placeholder_users_controller_spec.rbindex 48f65577951..69cc3469162 100644--- a/spec/controllers/placeholder_users_controller_spec.rb+++ b/spec/controllers/placeholder_users_controller_spec.rb@@ -106,7 +106,7 @@ describe PlaceholderUsersController, type: :controller doexpect(response).to be_successfulexpect(assigns(:errors).details[:base])- .to eq([error: :error_enterprise_only])+ .to eq([error: :error_enterprise_only, action: "Placeholder Users"])endenddiff --git a/spec/factories/notification_setting_factory.rb b/spec/factories/notification_setting_factory.rbindex 8fe73cd5334..b683d5c81fd 100644--- a/spec/factories/notification_setting_factory.rb+++ b/spec/factories/notification_setting_factory.rb@@ -26,7 +26,7 @@ FactoryBot.define docallback(:after_build, :after_stub) do |notification_setting, evaluator|if evaluator.all == true- all_boolean_settings = NotificationSetting.all_settings - NotificationSetting.duration_settings+ all_boolean_settings = NotificationSetting.all_settings - NotificationSetting.date_alert_settingsall_true = all_boolean_settings.index_with(true)notification_setting.assign_attributes(all_true)enddiff --git a/spec/lib/api/v3/user_preferences/notification_setting_representer_rendering_spec.rb b/spec/lib/api/v3/user_preferences/notification_setting_representer_rendering_spec.rbindex 936aff42d07..4b0db30a341 100644--- a/spec/lib/api/v3/user_preferences/notification_setting_representer_rendering_spec.rb+++ b/spec/lib/api/v3/user_preferences/notification_setting_representer_rendering_spec.rb@@ -69,7 +69,7 @@ describe ::API::V3::UserPreferences::NotificationSettingRepresenter, 'rendering'.not_to have_json_path('_type')end- (NotificationSetting.all_settings - NotificationSetting.duration_settings).each do |property|+ (NotificationSetting.all_settings - NotificationSetting.date_alert_settings).each do |property|it_behaves_like 'property', property.to_s.camelize(:lower) dolet(:value) donotification_setting.send property@@ -77,14 +77,24 @@ describe ::API::V3::UserPreferences::NotificationSettingRepresenter, 'rendering'endend- it_behaves_like 'property', :startDate do- let(:value) { 'P1D' }- end- it_behaves_like 'property', :dueDate do- let(:value) { 'P1D' }+ context 'without enterprise' do+ it 'does not have the date alert settings in the resulting json' do+ expect(subject).not_to have_json_path("startDate")+ expect(subject).not_to have_json_path("dueDate")+ expect(subject).not_to have_json_path("overdue")+ endend- it_behaves_like 'property', :overdue do- let(:value) { 'P3D' }++ context 'with enterprise', with_ee: %i[date_alerts] do+ it_behaves_like 'property', :startDate do+ let(:value) { 'P1D' }+ end+ it_behaves_like 'property', :dueDate do+ let(:value) { 'P1D' }+ end+ it_behaves_like 'property', :overdue do+ let(:value) { 'P3D' }+ endendenddiff --git a/spec/lib/api/v3/user_preferences/user_preference_representer_rendering_spec.rb b/spec/lib/api/v3/user_preferences/user_preference_representer_rendering_spec.rbindex ac628f56d9f..4fc340037ed 100644--- a/spec/lib/api/v3/user_preferences/user_preference_representer_rendering_spec.rb+++ b/spec/lib/api/v3/user_preferences/user_preference_representer_rendering_spec.rb@@ -76,7 +76,7 @@ describe ::API::V3::UserPreferences::UserPreferenceRepresenter,endend- describe 'notification_settings' do+ describe 'notification_settings', with_ee: %i[date_alerts] doit 'renders them as a nested array' doexpect(subject).to have_json_type(Array).at_path('notifications')expect(subject).to be_json_eql(nil.to_json).at_path('notifications/0/_links/project/href')diff --git a/spec/requests/api/v3/placeholder_users/create_shared_examples.rb b/spec/requests/api/v3/placeholder_users/create_shared_examples.rbindex 76172e347f2..449988c62fa 100644--- a/spec/requests/api/v3/placeholder_users/create_shared_examples.rb+++ b/spec/requests/api/v3/placeholder_users/create_shared_examples.rb@@ -94,7 +94,7 @@ shared_examples 'create placeholder user request flow' doexpect(last_response.status).to eq(422)expect(parsed_response['message'])- .to eq('is only available in the OpenProject Enterprise Edition')+ .to eq('Placeholder Users is only available in the OpenProject Enterprise Edition')expect(last_response.body).to be_json_eql('urn:openproject-org:api:v3:errors:PropertyConstraintViolation'.to_json)