[35506] Avoid notifications for assigned/responsible placeholders

Right now, placeholder users cannot be watchers nor authors nor meeting
participants, so the only notifications that can happen are work package
assignees or responsibles.

https://community.openproject.com/wp/35506
pull/8960/head
Oliver Günther 4 years ago
parent a8bbbdcf5a
commit e484804645
  1. 5
      app/models/work_package.rb
  2. 19
      spec/features/work_packages/tabs/watcher_tab_spec.rb
  3. 19
      spec/services/notifications/journal_wp_mail_service_spec.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

@ -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

@ -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) }

Loading…
Cancel
Save