X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fweb%2Fcommon_api%2Fcommon_api_test.exs;h=a7d9e61613b6f94785e3cf3298dcc5e4de4cc1e2;hb=501fba33d6bb02cca586cfeeac9fdcfec5c7436d;hp=652b5309924b3dd75502a17b59f139e57c060985;hpb=63dbd875684b192e57d356a194c5d07ad98bd810;p=akkoma
diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs
index 652b53099..a7d9e6161 100644
--- a/test/web/common_api/common_api_test.exs
+++ b/test/web/common_api/common_api_test.exs
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2018 Pleroma Authors
+# Copyright © 2017-2019 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.CommonAPI.Test do
@@ -17,6 +17,13 @@ defmodule Pleroma.Web.CommonAPI.Test do
assert activity.data["object"]["tag"] == ["2hu"]
end
+ test "it adds emoji in the object" do
+ user = insert(:user)
+ {:ok, activity} = CommonAPI.post(user, %{"status" => ":moominmamma:"})
+
+ assert activity.data["object"]["emoji"]["moominmamma"]
+ end
+
test "it adds emoji when updating profiles" do
user = insert(:user, %{name: ":karjalanpiirakka:"})
@@ -98,38 +105,63 @@ defmodule Pleroma.Web.CommonAPI.Test do
end
describe "pinned statuses" do
- test "pin status" do
+ setup do
Pleroma.Config.put([:instance, :max_pinned_statuses], 1)
- user = insert(:user)
+ user = insert(:user)
{:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!"})
+ [user: user, activity: activity]
+ end
+
+ test "pin status", %{user: user, activity: activity} do
assert {:ok, ^activity} = CommonAPI.pin(activity.id, user)
+
+ id = activity.id
+ user = refresh_record(user)
+
+ assert %User{info: %{pinned_activities: [^id]}} = user
end
- test "max pinned statuses" do
- Pleroma.Config.put([:instance, :max_pinned_statuses], 1)
+ test "only self-authored can be pinned", %{activity: activity} do
user = insert(:user)
- {:ok, activity_one} = CommonAPI.post(user, %{"status" => "HI!!!"})
+ assert {:error, "Could not pin"} = CommonAPI.pin(activity.id, user)
+ end
+
+ test "max pinned statuses", %{user: user, activity: activity_one} do
{:ok, activity_two} = CommonAPI.post(user, %{"status" => "HI!!!"})
assert {:ok, ^activity_one} = CommonAPI.pin(activity_one.id, user)
- user = User.get_by_ap_id(user.ap_id)
+ user = refresh_record(user)
- assert {:error, "You have already pinned the maximum number of toots"} =
+ assert {:error, "You have already pinned the maximum number of statuses"} =
CommonAPI.pin(activity_two.id, user)
end
- test "unpin status" do
- Pleroma.Config.put([:instance, :max_pinned_statuses], 1)
- user = insert(:user)
-
- {:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!"})
+ test "unpin status", %{user: user, activity: activity} do
{:ok, activity} = CommonAPI.pin(activity.id, user)
+ user = refresh_record(user)
+
assert {:ok, ^activity} = CommonAPI.unpin(activity.id, user)
+
+ user = refresh_record(user)
+
+ assert %User{info: %{pinned_activities: []}} = user
+ end
+
+ test "should unpin when deleting a status", %{user: user, activity: activity} do
+ {:ok, activity} = CommonAPI.pin(activity.id, user)
+
+ user = refresh_record(user)
+
+ assert {:ok, _} = CommonAPI.delete(activity.id, user)
+
+ user = refresh_record(user)
+
+ assert %User{info: %{pinned_activities: []}} = user
end
end
end