X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=test%2Fpleroma%2Factivity_test.exs;h=390a063447cadb040bbf47095c7f42983798e3ef;hb=cf4765af4098098fa4d6996193432bd19c439a75;hp=ee6a99cc36b76b638ca6e87f855915d81efcfb09;hpb=049ece1ef38f1aeb656a88ed1d15bf3d4a364e01;p=akkoma
diff --git a/test/pleroma/activity_test.exs b/test/pleroma/activity_test.exs
index ee6a99cc3..390a06344 100644
--- a/test/pleroma/activity_test.exs
+++ b/test/pleroma/activity_test.exs
@@ -1,5 +1,5 @@
# 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.ActivityTest do
@@ -25,7 +25,7 @@ defmodule Pleroma.ActivityTest do
test "returns activities by it's objects AP ids" do
activity = insert(:note_activity)
- object_data = Object.normalize(activity).data
+ object_data = Object.normalize(activity, fetch: false).data
[found_activity] = Activity.get_all_create_by_object_ap_id(object_data["id"])
@@ -34,7 +34,7 @@ defmodule Pleroma.ActivityTest do
test "returns the activity that created an object" do
activity = insert(:note_activity)
- object_data = Object.normalize(activity).data
+ object_data = Object.normalize(activity, fetch: false).data
found_activity = Activity.get_create_by_object_ap_id(object_data["id"])
@@ -168,7 +168,7 @@ defmodule Pleroma.ActivityTest do
test "find only local statuses for unauthenticated users when `limit_to_local_content` is `:all`",
%{local_activity: local_activity} do
- Pleroma.Config.put([:instance, :limit_to_local_content], :all)
+ clear_config([:instance, :limit_to_local_content], :all)
assert [^local_activity] = Activity.search(nil, "find me")
end
@@ -177,7 +177,7 @@ defmodule Pleroma.ActivityTest do
local_activity: local_activity,
remote_activity: remote_activity
} do
- Pleroma.Config.put([:instance, :limit_to_local_content], false)
+ clear_config([:instance, :limit_to_local_content], false)
activities = Enum.sort_by(Activity.search(nil, "find me"), & &1.id)
@@ -197,6 +197,13 @@ defmodule Pleroma.ActivityTest do
assert [%{id: ^id1, object: %Object{}}, %{id: ^id2, object: %Object{}}] = activities
end
+ test "get_by_id_with_user_actor/1" do
+ user = insert(:user)
+ activity = insert(:note_activity, note: insert(:note, user: user))
+
+ assert Activity.get_by_id_with_user_actor(activity.id).user_actor == user
+ end
+
test "get_by_id_with_object/1" do
%{id: id} = insert(:note_activity)
@@ -231,4 +238,20 @@ defmodule Pleroma.ActivityTest do
assert [%Activity{id: ^id1}, %Activity{id: ^id2}] = activities
end
+
+ test "get_by_object_ap_id_with_object/1" do
+ user = insert(:user)
+ another = insert(:user)
+
+ {:ok, %{id: id, object: %{data: %{"id" => obj_id}}}} =
+ Pleroma.Web.CommonAPI.post(user, %{status: "cofe"})
+
+ Pleroma.Web.CommonAPI.favorite(another, id)
+
+ assert obj_id
+ |> Pleroma.Activity.Queries.by_object_id()
+ |> Repo.aggregate(:count, :id) == 2
+
+ assert %{id: ^id} = Activity.get_by_object_ap_id_with_object(obj_id)
+ end
end