diff options
author | Roman Chvanikov <chvanikoff@pm.me> | 2020-08-05 19:16:48 +0300 |
---|---|---|
committer | Roman Chvanikov <chvanikoff@pm.me> | 2020-08-05 19:16:48 +0300 |
commit | 4672b61106044c3772f58b02d39531b015ad8cca (patch) | |
tree | 0c0844bab5eae07265965b2b6dbd914afc55f9d6 /test/web/common_api/common_api_test.exs | |
parent | 3116a75e80144dff79232c8676bd28ed285a14d9 (diff) | |
parent | 7755f49e281e4990db5317b33d6b8e0d12982e0c (diff) | |
download | pleroma-4672b61106044c3772f58b02d39531b015ad8cca.tar.gz pleroma-4672b61106044c3772f58b02d39531b015ad8cca.zip |
Merge branch 'develop' into command-available-check
Diffstat (limited to 'test/web/common_api/common_api_test.exs')
-rw-r--r-- | test/web/common_api/common_api_test.exs | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index 7e11fede3..4ba6232dc 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -458,6 +458,11 @@ defmodule Pleroma.Web.CommonAPITest do end describe "posting" do + test "deactivated users can't post" do + user = insert(:user, deactivated: true) + assert {:error, _} = CommonAPI.post(user, %{status: "ye"}) + end + test "it supports explicit addressing" do user = insert(:user) user_two = insert(:user) @@ -624,14 +629,27 @@ defmodule Pleroma.Web.CommonAPITest do user = insert(:user) other_user = insert(:user) - {:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"}) - {:ok, reaction} = CommonAPI.react_with_emoji(activity.id, user, "👍") + clear_config([:instance, :federating], true) + + with_mock Pleroma.Web.Federator, + publish: fn _ -> nil end do + {:ok, activity} = CommonAPI.post(other_user, %{status: "cofe"}) + {:ok, reaction} = CommonAPI.react_with_emoji(activity.id, user, "👍") + + {:ok, unreaction} = CommonAPI.unreact_with_emoji(activity.id, user, "👍") - {:ok, unreaction} = CommonAPI.unreact_with_emoji(activity.id, user, "👍") + assert unreaction.data["type"] == "Undo" + assert unreaction.data["object"] == reaction.data["id"] + assert unreaction.local - assert unreaction.data["type"] == "Undo" - assert unreaction.data["object"] == reaction.data["id"] - assert unreaction.local + # On federation, it contains the undone (and deleted) object + unreaction_with_object = %{ + unreaction + | data: Map.put(unreaction.data, "object", reaction.data) + } + + assert called(Pleroma.Web.Federator.publish(unreaction_with_object)) + end end test "repeating a status" do |