[#878] Refactored assumptions on embedded object presence in tests. Adjusted note...
[akkoma] / test / web / ostatus / incoming_documents / delete_handling_test.exs
index 412d894fd83b1f31c1c1b472e2e32273e1759cca..1fe714d00557f6d79fa62c57d944dea8605c8971 100644 (file)
@@ -6,7 +6,6 @@ defmodule Pleroma.Web.OStatus.DeleteHandlingTest do
 
   alias Pleroma.Activity
   alias Pleroma.Object
-  alias Pleroma.Repo
   alias Pleroma.Web.OStatus
 
   setup do
@@ -18,8 +17,9 @@ defmodule Pleroma.Web.OStatus.DeleteHandlingTest do
     test "it removes the mentioned activity" do
       note = insert(:note_activity)
       second_note = insert(:note_activity)
+      object = Object.normalize(note)
+      second_object = Object.normalize(second_note)
       user = insert(:user)
-      object = Object.get_by_ap_id(note.data["object"]["id"])
 
       {:ok, like, _object} = Pleroma.Web.ActivityPub.ActivityPub.like(user, object)
 
@@ -27,16 +27,16 @@ defmodule Pleroma.Web.OStatus.DeleteHandlingTest do
         File.read!("test/fixtures/delete.xml")
         |> String.replace(
           "tag:mastodon.sdf.org,2017-06-10:objectId=310513:objectType=Status",
-          note.data["object"]["id"]
+          object.data["id"]
         )
 
       {:ok, [delete]} = OStatus.handle_incoming(incoming)
 
-      refute Repo.get(Activity, note.id)
-      refute Repo.get(Activity, like.id)
-      assert Object.get_by_ap_id(note.data["object"]["id"]).data["type"] == "Tombstone"
-      assert Repo.get(Activity, second_note.id)
-      assert Object.get_by_ap_id(second_note.data["object"]["id"])
+      refute Activity.get_by_id(note.id)
+      refute Activity.get_by_id(like.id)
+      assert Object.get_by_ap_id(object.data["id"]).data["type"] == "Tombstone"
+      assert Activity.get_by_id(second_note.id)
+      assert Object.get_by_ap_id(second_object.data["id"])
 
       assert delete.data["type"] == "Delete"
     end