summaryrefslogtreecommitdiff
path: root/test/conversation_test.exs
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2019-05-15 17:47:29 +0200
committerlain <lain@soykaf.club>2019-05-15 17:47:29 +0200
commitf168a1cbdc318ffaa2d8bc9fb561eb3dfdfb89d9 (patch)
tree3c208baf52e27859491cce07954ac9b1198cbc8f /test/conversation_test.exs
parent786f2c7a849bc4fa2bd4aac18de59ef6b2ed18c5 (diff)
parent62516be9c462ca206163eaf7822f9ee5c2470453 (diff)
downloadpleroma-f168a1cbdc318ffaa2d8bc9fb561eb3dfdfb89d9.tar.gz
pleroma-f168a1cbdc318ffaa2d8bc9fb561eb3dfdfb89d9.zip
Merge remote-tracking branch 'origin/develop' into conversations-import
Diffstat (limited to 'test/conversation_test.exs')
-rw-r--r--test/conversation_test.exs38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/conversation_test.exs b/test/conversation_test.exs
index cdec18f0f..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
@@ -154,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