mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-26 01:31:16 +00:00
Apply review suggestions
This commit is contained in:
parent
a8918ebe86
commit
6240eff160
@ -390,7 +390,7 @@ class ForumMessage(models.Model):
|
||||
)
|
||||
|
||||
def is_deleted(self):
|
||||
if self.id is None:
|
||||
if self._state.adding:
|
||||
return False
|
||||
meta = self.metas.exclude(action="EDIT").order_by("-date").first()
|
||||
if meta:
|
||||
|
@ -16,9 +16,10 @@
|
||||
import pytest
|
||||
from django.test import Client
|
||||
from django.urls import reverse
|
||||
from pytest_django.asserts import assertRedirects
|
||||
|
||||
from core.models import User
|
||||
from forum.models import Forum, ForumTopic
|
||||
from forum.models import Forum, ForumMessage, ForumTopic
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@ -33,7 +34,13 @@ class TestTopicCreation:
|
||||
}
|
||||
assert not ForumTopic.objects.filter(_title=payload["title"]).first()
|
||||
response = client.post(reverse("forum:new_topic", args=str(forum.id)), payload)
|
||||
assert response.status_code == 302
|
||||
assertRedirects(
|
||||
response,
|
||||
expected_url=reverse(
|
||||
"forum:view_message", args=str(ForumMessage.objects.all().count())
|
||||
), # Get the last created message id
|
||||
target_status_code=302,
|
||||
)
|
||||
topic = ForumTopic.objects.filter(_title=payload["title"]).first()
|
||||
assert topic
|
||||
assert topic.last_message.message == payload["message"]
|
||||
|
Loading…
Reference in New Issue
Block a user