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)
assert represented_chat == %{
id: "#{chat.id}",
- account: AccountView.render("show.json", user: recipient),
+ account:
+ AccountView.render("show.json", user: recipient, skip_visibility_check: true),
unread: 0,
last_message: nil,
updated_at: Utils.to_masto_date(chat.updated_at)