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

[35506] Avoid notifications for assigned/responsible placeholders

Oliver Günthere4848046454a
diff --git a/app/models/work_package.rb b/app/models/work_package.rb
index e9f159cd38b..486f3b75f84 100644
--- a/app/models/work_package.rb
+++ b/app/models/work_package.rb
@@ -683,9 +683,10 @@ class WorkPackage < ApplicationRecord
related = [author]
[responsible, assigned_to].each do |user|
- if user.is_a?(Group)
+ case user
+ when Group
related += user.users
- else
+ when User
related << user
end
end
diff --git a/spec/features/work_packages/tabs/watcher_tab_spec.rb b/spec/features/work_packages/tabs/watcher_tab_spec.rb
index e02f92ea058..d4125f7ed1d 100644
--- a/spec/features/work_packages/tabs/watcher_tab_spec.rb
+++ b/spec/features/work_packages/tabs/watcher_tab_spec.rb
@@ -136,4 +136,23 @@ describe 'Watcher tab', js: true, selenium: true do
expect(page).to have_selector('.wp-tabs-count', text: 1)
end
end
+
+ context 'with a placeholder user in the project' do
+ let!(:placeholder) { FactoryBot.create :placeholder_user, name: 'PLACEHOLDER' }
+ let(:wp_page) { Pages::FullWorkPackage.new(work_package) }
+
+ before do
+ login_as(user)
+ wp_page.visit_tab! :watchers
+ end
+
+ it 'should not show the placeholder user as an option' do
+ autocomplete = find('.wp-watcher--autocomplete')
+ target_dropdown = search_autocomplete autocomplete,
+ query: ''
+
+ expect(target_dropdown).to have_selector(".ng-option", text: user.name)
+ expect(target_dropdown).to have_no_selector(".ng-option", text: placeholder.name)
+ end
+ end
end
diff --git a/spec/services/notifications/journal_wp_mail_service_spec.rb b/spec/services/notifications/journal_wp_mail_service_spec.rb
index 2da645a0ed2..1de94681d35 100644
--- a/spec/services/notifications/journal_wp_mail_service_spec.rb
+++ b/spec/services/notifications/journal_wp_mail_service_spec.rb
@@ -102,6 +102,25 @@ describe Notifications::JournalWpMailService do
it_behaves_like 'sends mail'
+ context 'assignee is placeholder user' do
+ let(:recipient) { FactoryBot.create :placeholder_user }
+
+ it_behaves_like 'sends no mail'
+ end
+
+ context 'responsible is placeholder user' do
+ let(:recipient) { FactoryBot.create :placeholder_user }
+ let(:work_package) do
+ FactoryBot.create(:work_package,
+ project: project,
+ author: author,
+ responsible: recipient,
+ type: project.types.first)
+ end
+
+ it_behaves_like 'sends no mail'
+ end
+
context 'notification for work_package_added disabled' do
let(:notification_setting) { %w(work_package_updated work_package_note_added) }