Skip to content

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

Must have enterprise token to create date alerts

Christophe Bliard4371b1c38744
diff --git a/app/services/authorization/enterprise_service.rb b/app/services/authorization/enterprise_service.rb
index 7a538aec1dc..5f50aa5f934 100644
--- a/app/services/authorization/enterprise_service.rb
+++ b/app/services/authorization/enterprise_service.rb
@@ -30,23 +30,24 @@ class Authorization::EnterpriseService
attr_accessor :token
GUARDED_ACTIONS = %i(
- define_custom_style
- multiselect_custom_fields
- edit_attribute_groups
- work_package_query_relation_columns
- attribute_help_texts
- two_factor_authentication
- ldap_groups
- custom_fields_in_projects_list
- custom_actions
- conditional_highlighting
- readonly_work_packages
attachment_filters
+ attribute_help_texts
board_view
+ conditional_highlighting
+ custom_actions
+ custom_fields_in_projects_list
+ date_alerts
+ define_custom_style
+ edit_attribute_groups
grid_widget_wp_graph
+ ldap_groups
+ multiselect_custom_fields
+ openid_providers
placeholder_users
+ readonly_work_packages
team_planner_view
- openid_providers
+ two_factor_authentication
+ work_package_query_relation_columns
).freeze
def initialize(token)
diff --git a/app/workers/notifications/create_date_alerts_notifications_job.rb b/app/workers/notifications/create_date_alerts_notifications_job.rb
index f5d927a4480..188a06d24fa 100644
--- a/app/workers/notifications/create_date_alerts_notifications_job.rb
+++ b/app/workers/notifications/create_date_alerts_notifications_job.rb
@@ -33,6 +33,8 @@ module Notifications
self.cron_expression = '*/15 * * * *'
def perform
+ return unless EnterpriseToken.allows_to?(:date_alerts)
+
time_zones = time_zones_covering_1am_local_time
return if time_zones.empty?
diff --git a/spec/workers/notifications/create_date_alerts_notifications_job_spec.rb b/spec/workers/notifications/create_date_alerts_notifications_job_spec.rb
index 0cd79208c68..ccd9e32bc06 100644
--- a/spec/workers/notifications/create_date_alerts_notifications_job_spec.rb
+++ b/spec/workers/notifications/create_date_alerts_notifications_job_spec.rb
@@ -28,7 +28,7 @@
require 'spec_helper'
-describe Notifications::CreateDateAlertsNotificationsJob, type: :job do
+describe Notifications::CreateDateAlertsNotificationsJob, type: :job, with_ee: %i[date_alerts] do
include ActiveSupport::Testing::TimeHelpers
shared_let(:project) { create(:project, name: 'main') }
@@ -240,6 +240,18 @@ describe Notifications::CreateDateAlertsNotificationsJob, type: :job do
end
end
+ context 'without enterprise token', with_ee: false do
+ it 'does not create any date alerts' do
+ work_package = alertable_work_package
+ set_scheduled_time(timezone_paris.now.change(hour: 1, min: 0))
+ travel_to(timezone_paris.now.change(hour: 1, min: 4)) do
+ scheduled_job.invoke_job
+
+ expect(user_paris).not_to have_a_start_date_alert_notification_for(work_package)
+ end
+ end
+ end
+
context 'when project notification settings are defined for a user' do
it 'creates date alert notifications using these settings for work packages of the project' do
# global notification settings