summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2020-06-05 12:01:33 +0200
committerlain <lain@soykaf.club>2020-06-05 12:01:33 +0200
commitcc8a7dc205a4516452c48659e6bf081f3f730496 (patch)
tree51e8e382cef023acc6500966c48f2c239d21ada3 /test
parentaa2ac76510d95f2412e23f3739e8e1ae4402643f (diff)
downloadpleroma-cc8a7dc205a4516452c48659e6bf081f3f730496.tar.gz
pleroma-cc8a7dc205a4516452c48659e6bf081f3f730496.zip
SideEffects / ChatView: Add an unread cache.
This is to prevent wrong values in the stream.
Diffstat (limited to 'test')
-rw-r--r--test/web/pleroma_api/views/chat_view_test.exs15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/web/pleroma_api/views/chat_view_test.exs b/test/web/pleroma_api/views/chat_view_test.exs
index f3bd12616..f77584dd1 100644
--- a/test/web/pleroma_api/views/chat_view_test.exs
+++ b/test/web/pleroma_api/views/chat_view_test.exs
@@ -16,6 +16,21 @@ defmodule Pleroma.Web.PleromaAPI.ChatViewTest do
import Pleroma.Factory
+ test "giving a chat with an 'unread' field, it uses that" do
+ user = insert(:user)
+ recipient = insert(:user)
+
+ {:ok, chat} = Chat.get_or_create(user.id, recipient.ap_id)
+
+ chat =
+ chat
+ |> Map.put(:unread, 5)
+
+ represented_chat = ChatView.render("show.json", chat: chat)
+
+ assert represented_chat[:unread] == 5
+ end
+
test "it represents a chat" do
user = insert(:user)
recipient = insert(:user)