ObjectView: do not fetch an object for its ID
[akkoma] / test / pleroma / web / activity_pub / views / object_view_test.exs
index f0389845dafd5733f5755673eaeb0e4dc1dd49c7..9348c09beff6ee94b9eb45d384fe827e71be2c90 100644 (file)
@@ -1,5 +1,5 @@
 # Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
 # SPDX-License-Identifier: AGPL-3.0-only
 
 defmodule Pleroma.Web.ActivityPub.ObjectViewTest do
@@ -24,7 +24,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectViewTest do
 
   test "renders a note activity" do
     note = insert(:note_activity)
-    object = Object.normalize(note)
+    object = Object.normalize(note, fetch: false)
 
     result = ObjectView.render("object.json", %{object: note})
 
@@ -56,7 +56,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectViewTest do
 
   test "renders a like activity" do
     note = insert(:note_activity)
-    object = Object.normalize(note)
+    object = Object.normalize(note, fetch: false)
     user = insert(:user)
 
     {:ok, like_activity} = CommonAPI.favorite(user, note.id)
@@ -70,7 +70,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectViewTest do
 
   test "renders an announce activity" do
     note = insert(:note_activity)
-    object = Object.normalize(note)
+    object = Object.normalize(note, fetch: false)
     user = insert(:user)
 
     {:ok, announce_activity} = CommonAPI.repeat(note.id, user)
@@ -81,4 +81,18 @@ defmodule Pleroma.Web.ActivityPub.ObjectViewTest do
     assert result["object"] == object.data["id"]
     assert result["type"] == "Announce"
   end
+
+  test "renders an undo announce activity" do
+    note = insert(:note_activity)
+    user = insert(:user)
+
+    {:ok, announce} = CommonAPI.repeat(note.id, user)
+    {:ok, undo} = CommonAPI.unrepeat(note.id, user)
+
+    result = ObjectView.render("object.json", %{object: undo})
+
+    assert result["id"] == undo.data["id"]
+    assert result["object"] == announce.data["id"]
+    assert result["type"] == "Undo"
+  end
 end