X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=test%2Factivity_test.exs;h=2a92327d136dec9768bcf13687acf0ec778baf35;hb=efdfc85c2d8e5118c1aa18e4f04026ec90cd11d2;hp=6512d84ac64b22ccdced6818c23756a89ffbda52;hpb=d75bc728e7e309174373e234079aa4825c81ab3e;p=akkoma
diff --git a/test/activity_test.exs b/test/activity_test.exs
index 6512d84ac..2a92327d1 100644
--- a/test/activity_test.exs
+++ b/test/activity_test.exs
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2018 Pleroma Authors
+# Copyright © 2017-2020 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.ActivityTest do
@@ -11,6 +11,11 @@ defmodule Pleroma.ActivityTest do
alias Pleroma.ThreadMute
import Pleroma.Factory
+ setup_all do
+ Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
+ :ok
+ end
+
test "returns an activity by it's AP id" do
activity = insert(:note_activity)
found_activity = Activity.get_by_ap_id(activity.data["id"])
@@ -107,8 +112,6 @@ defmodule Pleroma.ActivityTest do
describe "search" do
setup do
- Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
-
user = insert(:user)
params = %{
@@ -125,10 +128,28 @@ defmodule Pleroma.ActivityTest do
"to" => ["https://www.w3.org/ns/activitystreams#Public"]
}
- {:ok, local_activity} = Pleroma.Web.CommonAPI.post(user, %{"status" => "find me!"})
+ {:ok, local_activity} = Pleroma.Web.CommonAPI.post(user, %{status: "find me!"})
+ {:ok, japanese_activity} = Pleroma.Web.CommonAPI.post(user, %{status: "æ´æ°æ
å ±"})
{:ok, job} = Pleroma.Web.Federator.incoming_ap_doc(params)
{:ok, remote_activity} = ObanHelpers.perform(job)
- %{local_activity: local_activity, remote_activity: remote_activity, user: user}
+
+ %{
+ japanese_activity: japanese_activity,
+ local_activity: local_activity,
+ remote_activity: remote_activity,
+ user: user
+ }
+ end
+
+ setup do: clear_config([:instance, :limit_to_local_content])
+
+ test "finds utf8 text in statuses", %{
+ japanese_activity: japanese_activity,
+ user: user
+ } do
+ activities = Activity.search(user, "æ´æ°æ
å ±")
+
+ assert [^japanese_activity] = activities
end
test "find local and remote statuses for authenticated users", %{
@@ -149,7 +170,6 @@ defmodule Pleroma.ActivityTest do
%{local_activity: local_activity} do
Pleroma.Config.put([:instance, :limit_to_local_content], :all)
assert [^local_activity] = Activity.search(nil, "find me")
- Pleroma.Config.put([:instance, :limit_to_local_content], :unauthenticated)
end
test "find all statuses for unauthenticated users when `limit_to_local_content` is `false`",
@@ -162,8 +182,6 @@ defmodule Pleroma.ActivityTest do
activities = Enum.sort_by(Activity.search(nil, "find me"), & &1.id)
assert [^local_activity, ^remote_activity] = activities
-
- Pleroma.Config.put([:instance, :limit_to_local_content], :unauthenticated)
end
end
@@ -210,8 +228,8 @@ defmodule Pleroma.ActivityTest do
test "all_by_actor_and_id/2" do
user = insert(:user)
- {:ok, %{id: id1}} = Pleroma.Web.CommonAPI.post(user, %{"status" => "cofe"})
- {:ok, %{id: id2}} = Pleroma.Web.CommonAPI.post(user, %{"status" => "cofefe"})
+ {:ok, %{id: id1}} = Pleroma.Web.CommonAPI.post(user, %{status: "cofe"})
+ {:ok, %{id: id2}} = Pleroma.Web.CommonAPI.post(user, %{status: "cofefe"})
assert [] == Activity.all_by_actor_and_id(user, [])