From 495b332aa801cd308b95b7129e7a60736fdd8abf Mon Sep 17 00:00:00 2001 From: Alberto Leal Date: Tue, 28 Feb 2023 16:22:20 -0500 Subject: [PATCH] fix(hybrid-cloud): Uncache organization when queueing it for deletion --- src/sentry/api/endpoints/organization_details.py | 1 + tests/sentry/api/endpoints/test_organization_details.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/sentry/api/endpoints/organization_details.py b/src/sentry/api/endpoints/organization_details.py index 0a0d3d35d71a67..01b023250fd870 100644 --- a/src/sentry/api/endpoints/organization_details.py +++ b/src/sentry/api/endpoints/organization_details.py @@ -598,6 +598,7 @@ def handle_delete(self, request: Request, organization): transaction_id=schedule.guid, ) organization.send_delete_confirmation(entry, ONE_DAY) + Organization.objects.uncache_object(organization.id) context = serialize( organization, request.user, diff --git a/tests/sentry/api/endpoints/test_organization_details.py b/tests/sentry/api/endpoints/test_organization_details.py index 6d32f0447c6d56..7edec28595868d 100644 --- a/tests/sentry/api/endpoints/test_organization_details.py +++ b/tests/sentry/api/endpoints/test_organization_details.py @@ -819,6 +819,10 @@ def test_can_remove_as_owner(self): # No owners should be remaining assert len(owner_emails) == 0 + # Ensure cache was flushed + org = Organization.objects.get_from_cache(slug=org.slug) + assert org.status == OrganizationStatus.PENDING_DELETION + def test_cannot_remove_as_admin(self): org = self.create_organization(owner=self.user) user = self.create_user(email="foo@example.com", is_superuser=False)