Use same context for quote posts as the post that's being quoted (#379)
[akkoma] / test / pleroma / announcement_read_relationship_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.AnnouncementReadRelationshipTest do
6 alias Pleroma.AnnouncementReadRelationship
7
8 use Pleroma.DataCase, async: true
9
10 import Pleroma.Factory
11
12 setup do
13 {:ok, user: insert(:user), announcement: insert(:announcement)}
14 end
15
16 describe "mark_read/2" do
17 test "should insert relationship", %{user: user, announcement: announcement} do
18 {:ok, _} = AnnouncementReadRelationship.mark_read(user, announcement)
19
20 assert AnnouncementReadRelationship.exists?(user, announcement)
21 end
22 end
23
24 describe "mark_unread/2" do
25 test "should delete relationship", %{user: user, announcement: announcement} do
26 {:ok, _} = AnnouncementReadRelationship.mark_read(user, announcement)
27
28 assert :ok = AnnouncementReadRelationship.mark_unread(user, announcement)
29 refute AnnouncementReadRelationship.exists?(user, announcement)
30 end
31
32 test "should not fail if relationship does not exist", %{
33 user: user,
34 announcement: announcement
35 } do
36 assert :ok = AnnouncementReadRelationship.mark_unread(user, announcement)
37 refute AnnouncementReadRelationship.exists?(user, announcement)
38 end
39 end
40 end