X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=test%2Fconversation_test.exs;h=5903d10ff05b1ffd94b4d4594952a1b393283b6f;hb=ad5263c647aea65dbeb4c329825671895e0a8863;hp=59368b0e7dba3f86ef4dbcc01e373235c670baa7;hpb=fcf2f38d20eed40a53b03374467d9e52b013da07;p=akkoma diff --git a/test/conversation_test.exs b/test/conversation_test.exs index 59368b0e7..5903d10ff 100644 --- a/test/conversation_test.exs +++ b/test/conversation_test.exs @@ -4,7 +4,9 @@ defmodule Pleroma.ConversationTest do use Pleroma.DataCase + alias Pleroma.Activity alias Pleroma.Conversation + alias Pleroma.Object alias Pleroma.Web.CommonAPI import Pleroma.Factory @@ -24,7 +26,9 @@ defmodule Pleroma.ConversationTest do Conversation.bump_for_all_activities() assert Repo.one(Conversation) - assert length(Repo.all(Conversation.Participation)) == 2 + [participation, _p2] = Repo.all(Conversation.Participation) + + assert participation.read end test "it creates a conversation for given ap_id" do @@ -152,4 +156,40 @@ defmodule Pleroma.ConversationTest do assert {:error, _} = Conversation.create_or_bump_for(activity) end + + test "create_or_bump_for does not normalize objects before checking the activity type" do + note = insert(:note) + note_id = note.data["id"] + Repo.delete(note) + refute Object.get_by_ap_id(note_id) + + Tesla.Mock.mock(fn env -> + case env.url do + ^note_id -> + # TODO: add attributedTo and tag to the note factory + body = + note.data + |> Map.put("attributedTo", note.data["actor"]) + |> Map.put("tag", []) + |> Jason.encode!() + + %Tesla.Env{status: 200, body: body} + end + end) + + undo = %Activity{ + id: "fake", + data: %{ + "id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id(), + "actor" => note.data["actor"], + "to" => [note.data["actor"]], + "object" => note_id, + "type" => "Undo" + } + } + + Conversation.create_or_bump_for(undo) + + refute Object.get_by_ap_id(note_id) + end end