Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deletions) Fix servicehooks blocking project deletion #28697

Merged
merged 1 commit into from
Sep 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/sentry/deletions/defaults/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def get_child_relations(self, instance):
PromptsActivity,
Release,
Repository,
ServiceHook,
Team,
)

Expand All @@ -36,6 +37,7 @@ def get_child_relations(self, instance):
model_list = (
OrganizationMember,
Repository,
ServiceHook,
CommitAuthor,
Release,
Project,
Expand Down
1 change: 1 addition & 0 deletions src/sentry/deletions/defaults/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def get_child_relations(self, instance):
models.RepositoryProjectPathConfig,
models.SavedSearchUserDefault,
models.SavedSearch,
models.ServiceHookProject,
models.ServiceHook,
models.UserReport,
models.ProjectTransactionThreshold,
Expand Down
8 changes: 8 additions & 0 deletions tests/sentry/deletions/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
ReleaseCommit,
Repository,
ScheduledDeletion,
ServiceHook,
)
from sentry.tasks.deletion import run_deletion
from sentry.testutils import TransactionTestCase
Expand Down Expand Up @@ -68,6 +69,12 @@ def test_simple(self):
type=file_attachment.type,
name="hello.png",
)
hook = self.create_service_hook(
actor=self.user,
org=project.organization,
project=project,
url="https://example.com/webhook",
)

deletion = ScheduledDeletion.schedule(project, days=0)
deletion.update(in_progress=True)
Expand All @@ -87,3 +94,4 @@ def test_simple(self):
assert Commit.objects.filter(id=commit.id).exists()
assert not ProjectDebugFile.objects.filter(id=dif.id).exists()
assert not File.objects.filter(id=file.id).exists()
assert not ServiceHook.objects.filter(id=hook.id).exists()