Fix feedback email test for on_commit task enqueue
Execute on_commit callbacks so OutboundEmail ImmediateBackend send runs inside TestCase transactions, matching invite/reset coverage.
This commit is contained in:
@@ -375,6 +375,7 @@ class FeedbackViewTestCase(APITestCase):
|
|||||||
self.url = reverse("feedbacks")
|
self.url = reverse("feedbacks")
|
||||||
|
|
||||||
def test_post_creates_feedback_and_notifies(self):
|
def test_post_creates_feedback_and_notifies(self):
|
||||||
|
with self.captureOnCommitCallbacks(execute=True):
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
self.url,
|
self.url,
|
||||||
{"title": "Broken button", "text": "It does nothing"},
|
{"title": "Broken button", "text": "It does nothing"},
|
||||||
@@ -386,6 +387,9 @@ class FeedbackViewTestCase(APITestCase):
|
|||||||
self.assertEqual(feedback.user, self.user)
|
self.assertEqual(feedback.user, self.user)
|
||||||
self.assertEqual(len(mail.outbox), 1)
|
self.assertEqual(len(mail.outbox), 1)
|
||||||
self.assertIn("Broken button", mail.outbox[0].body)
|
self.assertIn("Broken button", mail.outbox[0].body)
|
||||||
|
outbound = OutboundEmail.objects.get(user=self.user)
|
||||||
|
self.assertEqual(outbound.kind, OutboundEmail.Kind.FEEDBACK)
|
||||||
|
self.assertEqual(outbound.status, OutboundEmail.Status.SENT)
|
||||||
|
|
||||||
def test_post_without_text_is_rejected(self):
|
def test_post_without_text_is_rejected(self):
|
||||||
response = self.client.post(self.url, {"title": "no body"}, format="json")
|
response = self.client.post(self.url, {"title": "no body"}, format="json")
|
||||||
|
|||||||
Reference in New Issue
Block a user