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

Fix error on Mails::WatcherJob missing notification_settings

Dombi Attilabd9cb9ef678e
diff --git a/app/workers/mails/watcher_job.rb b/app/workers/mails/watcher_job.rb
index 043b54e0a27..37729e8e306 100644
--- a/app/workers/mails/watcher_job.rb
+++ b/app/workers/mails/watcher_job.rb
@@ -61,6 +61,8 @@ class Mails::WatcherJob < Mails::DeliverJob
.applicable(watcher.watchable.project)
.first
+ return false if settings.nil?
+
settings.watched
end
diff --git a/spec/workers/mails/shared/watcher_job.rb b/spec/workers/mails/shared/watcher_job.rb
index 54c8f18a158..3e025cdcd8a 100644
--- a/spec/workers/mails/shared/watcher_job.rb
+++ b/spec/workers/mails/shared/watcher_job.rb
@@ -147,4 +147,11 @@ shared_examples "watcher job" do |action|
[build_stubbed(:notification_setting, mentioned: true, involved: false, watched: false)]
end
end
+
+ it_behaves_like 'does not notify the watcher' do
+ # Regression test for notification settings being empty
+ let(:notification_settings) do
+ []
+ end
+ end
end