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
fix[Op#52449]: Do not schedule daily notification job if unsubscribed
Kabiru Mwenja2f4f06f33e28
diff --git a/modules/storages/app/services/storages/health_service.rb b/modules/storages/app/services/storages/health_service.rbindex 403b8ccbbdd..b25d798937f 100644--- a/modules/storages/app/services/storages/health_service.rb+++ b/modules/storages/app/services/storages/health_service.rb@@ -96,6 +96,8 @@ module Storagesenddef schedule_mail_job(storage)+ return unless storage.health_notifications_enabled?+::Storages::HealthStatusMailerJob.schedule(storage:)enddiff --git a/modules/storages/spec/services/storages/health_service_spec.rb b/modules/storages/spec/services/storages/health_service_spec.rbindex e1a0bdd35c3..331d626d723 100644--- a/modules/storages/spec/services/storages/health_service_spec.rb+++ b/modules/storages/spec/services/storages/health_service_spec.rb@@ -131,32 +131,43 @@ RSpec.describe Storages::HealthService doit "notifies admin users when the storage becomes healthy" doexpect dohealth_service.healthy- end.to have_enqueued_mail(Storages::StoragesMailer, :notify_healthy)- .with(admin_user, storage, storage.health_reason).at_most(:once)+ end.to(have_enqueued_mail(+ Storages::StoragesMailer, :notify_healthy+ ).with(admin_user, storage, storage.health_reason).at_most(:once)+ .and(have_enqueued_job(Storages::HealthStatusMailerJob).with(storage:).at_most(:once)))endit "notifies admin users when the storage becomes unhealthy" doexpect dohealth_service.unhealthy(reason: "thou_shall_not_pass_error")- end.to have_enqueued_mail(Storages::StoragesMailer, :notify_unhealthy).with(admin_user, storage).at_most(:once)+ end.to(have_enqueued_mail(+ Storages::StoragesMailer, :notify_unhealthy+ ).with(admin_user, storage).at_most(:once)+ .and(have_enqueued_job(Storages::HealthStatusMailerJob).with(storage:).at_most(:once)))endendcontext "when the storage has notifications disabled" dobefore dostorage.update(health_notifications_enabled: false)++ allow(Storages::HealthStatusMailerJob).to receive(:schedule).and_call_originalendit "does not notify admin users when the storage becomes healthy" doexpect dohealth_service.healthyend.not_to have_enqueued_mail(Storages::StoragesMailer, :notify_healthy)++ expect(Storages::HealthStatusMailerJob).not_to have_received(:schedule)endit "does not notify admin users when the storage becomes unhealthy" doexpect dohealth_service.unhealthy(reason: "thou_shall_not_pass_error")end.not_to have_enqueued_mail(Storages::StoragesMailer, :notify_unhealthy)++ expect(Storages::HealthStatusMailerJob).not_to have_received(:schedule)endendend