mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-03 16:32:15 +02:00
test case written
This commit is contained in:
parent
1179a6a6b7
commit
100e3cf300
2 changed files with 15 additions and 1 deletions
|
@ -665,6 +665,20 @@ class TestDomainManagers(TestDomainOverview):
|
|||
with self.assertRaises(DomainInvitation.DoesNotExist):
|
||||
DomainInvitation.objects.get(id=invitation.id)
|
||||
|
||||
def test_domain_invitation_cancel_retrieved_invitation(self):
|
||||
"""Posting to the delete view when invitation retrieved returns an error message"""
|
||||
email_address = "mayor@igorville.gov"
|
||||
invitation, _ = DomainInvitation.objects.get_or_create(domain=self.domain, email=email_address, status=DomainInvitation.DomainInvitationStatus.RETRIEVED)
|
||||
with less_console_noise():
|
||||
response = self.client.post(reverse("invitation-delete", kwargs={"pk": invitation.id}), follow=True)
|
||||
# Assert that an error message is displayed to the user
|
||||
self.assertContains(response, f"Invitation to {email_address} has already been retrieved.")
|
||||
# Assert that the Cancel link is not displayed
|
||||
self.assertNotContains(response, "Cancel")
|
||||
# Assert that the DomainInvitation is not deleted
|
||||
self.assertTrue(DomainInvitation.objects.filter(id=invitation.id).exists())
|
||||
DomainInvitation.objects.filter(email=email_address).delete()
|
||||
|
||||
def test_domain_invitation_cancel_no_permissions(self):
|
||||
"""Posting to the delete view as a different user should fail."""
|
||||
email_address = "mayor@igorville.gov"
|
||||
|
|
|
@ -831,7 +831,7 @@ class DomainInvitationDeleteView(SuccessMessageMixin, DomainInvitationPermission
|
|||
return self.form_valid(form)
|
||||
else:
|
||||
# Produce an error message if the domain invatation status is RETRIEVED
|
||||
messages.error(request, f"Invitation to {self.object.email} has already been retrieved")
|
||||
messages.error(request, f"Invitation to {self.object.email} has already been retrieved.")
|
||||
return HttpResponseRedirect(self.get_success_url())
|
||||
|
||||
def get_success_url(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue