X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=inline;f=test%2Fpleroma%2Fweb%2Factivity_pub%2Fmrf%2Fensure_re_prepended_test.exs;h=e174a83f7e7d441bd0b0b4dd1fe2278af74a747c;hb=e3085c495c221b52f40c95a9beab33e51f02d81b;hp=9a283f27d6b3330532e06ed5fd525a56f022eb96;hpb=7bbc328d66aaac8d680f52521c6823aea42821af;p=akkoma
diff --git a/test/pleroma/web/activity_pub/mrf/ensure_re_prepended_test.exs b/test/pleroma/web/activity_pub/mrf/ensure_re_prepended_test.exs
index 9a283f27d..e174a83f7 100644
--- a/test/pleroma/web/activity_pub/mrf/ensure_re_prepended_test.exs
+++ b/test/pleroma/web/activity_pub/mrf/ensure_re_prepended_test.exs
@@ -1,12 +1,13 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.MRF.EnsureRePrependedTest do
- use Pleroma.DataCase
+ use Pleroma.DataCase, async: true
alias Pleroma.Activity
alias Pleroma.Object
+ alias Pleroma.Web.ActivityPub.MRF
alias Pleroma.Web.ActivityPub.MRF.EnsureRePrepended
describe "rewrites summary" do
@@ -35,10 +36,58 @@ defmodule Pleroma.Web.ActivityPub.MRF.EnsureRePrependedTest do
assert {:ok, res} = EnsureRePrepended.filter(message)
assert res["object"]["summary"] == "re: object-summary"
end
+
+ test "it adds `re:` to history" do
+ message = %{
+ "type" => "Create",
+ "object" => %{
+ "summary" => "object-summary",
+ "inReplyTo" => %Activity{object: %Object{data: %{"summary" => "object-summary"}}},
+ "formerRepresentations" => %{
+ "orderedItems" => [
+ %{
+ "summary" => "object-summary",
+ "inReplyTo" => %Activity{object: %Object{data: %{"summary" => "object-summary"}}}
+ }
+ ]
+ }
+ }
+ }
+
+ assert {:ok, res} = MRF.filter_one(EnsureRePrepended, message)
+ assert res["object"]["summary"] == "re: object-summary"
+
+ assert Enum.at(res["object"]["formerRepresentations"]["orderedItems"], 0)["summary"] ==
+ "re: object-summary"
+ end
+
+ test "it accepts Updates" do
+ message = %{
+ "type" => "Update",
+ "object" => %{
+ "summary" => "object-summary",
+ "inReplyTo" => %Activity{object: %Object{data: %{"summary" => "object-summary"}}},
+ "formerRepresentations" => %{
+ "orderedItems" => [
+ %{
+ "summary" => "object-summary",
+ "inReplyTo" => %Activity{object: %Object{data: %{"summary" => "object-summary"}}}
+ }
+ ]
+ }
+ }
+ }
+
+ assert {:ok, res} = MRF.filter_one(EnsureRePrepended, message)
+ assert res["object"]["summary"] == "re: object-summary"
+
+ assert Enum.at(res["object"]["formerRepresentations"]["orderedItems"], 0)["summary"] ==
+ "re: object-summary"
+ end
end
describe "skip filter" do
- test "it skip if type isn't 'Create'" do
+ test "it skip if type isn't 'Create' or 'Update'" do
message = %{
"type" => "Annotation",
"object" => %{"summary" => "object-summary"}