1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ActivityPub.MRF.EnsureRePrependedTest do
6 use Pleroma.DataCase, async: true
10 alias Pleroma.Web.ActivityPub.MRF.EnsureRePrepended
12 describe "rewrites summary" do
13 test "it adds `re:` to summary object when child summary and parent summary equal" do
17 "summary" => "object-summary",
18 "inReplyTo" => %Activity{object: %Object{data: %{"summary" => "object-summary"}}}
22 assert {:ok, res} = EnsureRePrepended.filter(message)
23 assert res["object"]["summary"] == "re: object-summary"
26 test "it adds `re:` to summary object when child summary containts re-subject of parent summary " do
30 "summary" => "object-summary",
31 "inReplyTo" => %Activity{object: %Object{data: %{"summary" => "re: object-summary"}}}
35 assert {:ok, res} = EnsureRePrepended.filter(message)
36 assert res["object"]["summary"] == "re: object-summary"
40 describe "skip filter" do
41 test "it skip if type isn't 'Create'" do
43 "type" => "Annotation",
44 "object" => %{"summary" => "object-summary"}
47 assert {:ok, res} = EnsureRePrepended.filter(message)
51 test "it skip if summary is empty" do
55 "inReplyTo" => %Activity{object: %Object{data: %{"summary" => "summary"}}}
59 assert {:ok, res} = EnsureRePrepended.filter(message)
63 test "it skip if inReplyTo is empty" do
64 message = %{"type" => "Create", "object" => %{"summary" => "summary"}}
65 assert {:ok, res} = EnsureRePrepended.filter(message)
69 test "it skip if parent and child summary isn't equal" do
73 "summary" => "object-summary",
74 "inReplyTo" => %Activity{object: %Object{data: %{"summary" => "summary"}}}
78 assert {:ok, res} = EnsureRePrepended.filter(message)
82 test "it skips if the object is only a reference" do
85 "object" => "somereference"
88 assert {:ok, res} = EnsureRePrepended.filter(message)