Skip to content

Commit

Permalink
let get_serialized_messages manage topic_head post
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed Nov 27, 2024
1 parent c4ad74f commit 89d4bba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions lacommunaute/notification/tests/tests_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ def test_order_by_date_joined(self):


class TestGetSerializedMessages:
def test_post_is_topic_head(self, db):
topic = TopicFactory(with_post=True)
notifications = [NotificationFactory(post=topic.first_post)]
assert get_serialized_messages(notifications) == [
{
"poster": topic.first_post.poster_display_name,
"action": "a posé une nouvelle question",
"forum": topic.forum.name,
"url": topic.get_absolute_url(with_fqdn=True),
}
]

def test_post_is_not_topic_head(self, db):
post = PostFactory(topic=TopicFactory(with_post=True))
notifications = [NotificationFactory(post=post)]
Expand Down
2 changes: 1 addition & 1 deletion lacommunaute/notification/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def get_serialized_messages(notifications):
return [
{
"poster": n.post.poster_display_name,
"action": f"a répondu à '{n.post.subject}'",
"action": "a posé une nouvelle question" if n.post.is_topic_head else f"a répondu à '{n.post.subject}'",
"forum": n.post.topic.forum.name,
"url": n.post.topic.get_absolute_url(with_fqdn=True),
}
Expand Down

0 comments on commit 89d4bba

Please sign in to comment.