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
enable default notifications on project copy
ulfertse6e5f9caab6c
diff --git a/app/services/base_services/copy.rb b/app/services/base_services/copy.rbindex cb37d14c4e1..7f6dba38dff 100644--- a/app/services/base_services/copy.rb+++ b/app/services/base_services/copy.rb@@ -91,12 +91,6 @@ module BaseServicesprotected- ##- # Disabling sending regular notifications- def service_context(*, &)- in_context(model, send_notifications: false, &)- end-### Should the dependency be skipped for this service run?def skip_dependency?(_params, _dependency_cls)diff --git a/app/workers/copy_project_job.rb b/app/workers/copy_project_job.rbindex 53583a4dd97..75aae3cc35a 100644--- a/app/workers/copy_project_job.rb+++ b/app/workers/copy_project_job.rb@@ -154,7 +154,7 @@ class CopyProjectJob < ApplicationJobenddef copy_project_params- params = { target_project_params: }+ params = { target_project_params:, send_notifications: send_mails }params[:only] = associations_to_copy if associations_to_copy.present?paramsdiff --git a/spec/services/projects/copy_service_integration_spec.rb b/spec/services/projects/copy_service_integration_spec.rbindex 1a2271fd46d..4855330662e 100644--- a/spec/services/projects/copy_service_integration_spec.rb+++ b/spec/services/projects/copy_service_integration_spec.rb@@ -609,8 +609,14 @@ describe Projects::CopyService, 'integration', type: :model doenddescribe 'assigned_to' do+ let(:assigned_user) do+ create(:user,+ member_in_project: source,+ member_through_role: role)+ end+before do- work_package.update_column(:assigned_to_id, current_user.id)+ work_package.update_column(:assigned_to_id, assigned_user.id)endcontext 'with the members being copied' do@@ -618,9 +624,13 @@ describe Projects::CopyService, 'integration', type: :model doit 'copies the assigned_to' doexpect(subject).to be_success- expect(project_copy.users).to include current_userexpect(project_copy.work_packages[0].assigned_to)- .to eql current_user+ .to eql assigned_user+ # The assignee of the new work package receives a notification+ expect { perform_enqueued_jobs }+ .to change(Notification.where(recipient: assigned_user), :count)+ .from(0)+ .to(1)endend@@ -631,13 +641,22 @@ describe Projects::CopyService, 'integration', type: :model doexpect(subject).to be_successexpect(project_copy.work_packages[0].assigned_to).to be_nil+ # No notification is sent out+ expect { perform_enqueued_jobs }+ .not_to change(Notification.where(recipient: assigned_user), :count)endendenddescribe 'responsible' do+ let(:responsible_user) do+ create(:user,+ member_in_project: source,+ member_through_role: role)+ end+before do- work_package.update_column(:responsible_id, current_user.id)+ work_package.update_column(:responsible_id, responsible_user.id)endcontext 'with the members being copied' do@@ -645,9 +664,13 @@ describe Projects::CopyService, 'integration', type: :model doit 'copies the responsible' doexpect(subject).to be_success- expect(project_copy.users).to include current_userexpect(project_copy.work_packages[0].responsible)- .to eql current_user+ .to eql responsible_user+ # The responsible of the new work package receives a notification+ expect { perform_enqueued_jobs }+ .to change(Notification.where(recipient: responsible_user), :count)+ .from(0)+ .to(1)endend@@ -658,6 +681,9 @@ describe Projects::CopyService, 'integration', type: :model doexpect(subject).to be_successexpect(project_copy.work_packages[0].responsible).to be_nil+ # No notification is sent out+ expect { perform_enqueued_jobs }+ .not_to change(Notification.where(recipient: responsible_user), :count)endendend