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

don't send notification when only some project roles, but not member itself is deleted

Ivan Kuchin532fe3638954
diff --git a/app/services/members/delete_service.rb b/app/services/members/delete_service.rb
index 87335a13b61..860c82069eb 100644
--- a/app/services/members/delete_service.rb
+++ b/app/services/members/delete_service.rb
@@ -44,7 +44,7 @@ class Members::DeleteService < BaseServices::Delete
member = call.result
cleanup_for_group(member)
- send_notification(member)
+ send_notification(member) if member.destroyed?
end
end
diff --git a/spec/services/members/delete_service_spec.rb b/spec/services/members/delete_service_spec.rb
index 1832391432a..4cb3105dd49 100644
--- a/spec/services/members/delete_service_spec.rb
+++ b/spec/services/members/delete_service_spec.rb
@@ -35,6 +35,12 @@ RSpec.describe Members::DeleteService, type: :model do
before do
model_instance.principal = principal
+ allow(model_instance).to receive(:destroy) do
+ allow(model_instance).to receive(:destroyed?).and_return(model_destroy_result)
+
+ model_destroy_result
+ end
+
allow(OpenProject::Notifications)
.to receive(:send)
end
@@ -120,6 +126,19 @@ RSpec.describe Members::DeleteService, type: :model do
it "is successful" do
expect(subject).to be_success
end
+
+ it "calls the cleanup service" do
+ service_call
+
+ expect(cleanup_service_instance)
+ .to have_received(:call)
+ end
+
+ it "doesn't send a notification" do
+ service_call
+
+ expect(OpenProject::Notifications).not_to have_received(:send)
+ end
end
end
end