Merge remote-tracking branch 'upstream/develop' into admin-create-users
[akkoma] / test / web / ostatus / incoming_documents / delete_handling_test.exs
1 defmodule Pleroma.Web.OStatus.DeleteHandlingTest do
2 use Pleroma.DataCase
3
4 import Pleroma.Factory
5 import Tesla.Mock
6
7 alias Pleroma.Activity
8 alias Pleroma.Object
9 alias Pleroma.Web.OStatus
10
11 setup do
12 mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
13 :ok
14 end
15
16 describe "deletions" do
17 test "it removes the mentioned activity" do
18 note = insert(:note_activity)
19 second_note = insert(:note_activity)
20 user = insert(:user)
21 object = Object.get_by_ap_id(note.data["object"]["id"])
22
23 {:ok, like, _object} = Pleroma.Web.ActivityPub.ActivityPub.like(user, object)
24
25 incoming =
26 File.read!("test/fixtures/delete.xml")
27 |> String.replace(
28 "tag:mastodon.sdf.org,2017-06-10:objectId=310513:objectType=Status",
29 note.data["object"]["id"]
30 )
31
32 {:ok, [delete]} = OStatus.handle_incoming(incoming)
33
34 refute Activity.get_by_id(note.id)
35 refute Activity.get_by_id(like.id)
36 assert Object.get_by_ap_id(note.data["object"]["id"]).data["type"] == "Tombstone"
37 assert Activity.get_by_id(second_note.id)
38 assert Object.get_by_ap_id(second_note.data["object"]["id"])
39
40 assert delete.data["type"] == "Delete"
41 end
42 end
43 end