summaryrefslogtreecommitdiff
path: root/test/web/common_api/common_api_test.exs
diff options
context:
space:
mode:
authorlambda <pleromagit@rogerbraun.net>2018-12-14 08:26:08 +0000
committerlambda <pleromagit@rogerbraun.net>2018-12-14 08:26:08 +0000
commit262cc6d44b2e77807373cfaff730c938112c5891 (patch)
tree1743aecf9800572403ddb4a9895f15d604a6a7e3 /test/web/common_api/common_api_test.exs
parent82dbd2d64fcd95361e5ebe510c8f5ed46bcaad1e (diff)
parent1ca080c8628d261cdb95145331aa36e631e90a3f (diff)
downloadpleroma-262cc6d44b2e77807373cfaff730c938112c5891.tar.gz
pleroma-262cc6d44b2e77807373cfaff730c938112c5891.zip
Merge branch 'fix/double-rt-or-fav' into 'develop'
Prevent accidental double RTs or favorites See merge request pleroma/pleroma!542
Diffstat (limited to 'test/web/common_api/common_api_test.exs')
-rw-r--r--test/web/common_api/common_api_test.exs39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs
index 8fc65f4c0..0b5a235f8 100644
--- a/test/web/common_api/common_api_test.exs
+++ b/test/web/common_api/common_api_test.exs
@@ -2,6 +2,7 @@ defmodule Pleroma.Web.CommonAPI.Test do
use Pleroma.DataCase
alias Pleroma.Web.CommonAPI
alias Pleroma.User
+ alias Pleroma.Activity
import Pleroma.Factory
@@ -53,4 +54,42 @@ defmodule Pleroma.Web.CommonAPI.Test do
assert content == "<p><b>2hu</b></p>alert('xss')"
end
end
+
+ describe "reactions" do
+ test "repeating a status" do
+ user = insert(:user)
+ other_user = insert(:user)
+
+ {:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
+
+ {:ok, %Activity{}, _} = CommonAPI.repeat(activity.id, user)
+ end
+
+ test "favoriting a status" do
+ user = insert(:user)
+ other_user = insert(:user)
+
+ {:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
+
+ {:ok, %Activity{}, _} = CommonAPI.favorite(activity.id, user)
+ end
+
+ test "retweeting a status twice returns an error" do
+ user = insert(:user)
+ other_user = insert(:user)
+
+ {:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
+ {:ok, %Activity{}, _object} = CommonAPI.repeat(activity.id, user)
+ {:error, _} = CommonAPI.repeat(activity.id, user)
+ end
+
+ test "favoriting a status twice returns an error" do
+ user = insert(:user)
+ other_user = insert(:user)
+
+ {:ok, activity} = CommonAPI.post(other_user, %{"status" => "cofe"})
+ {:ok, %Activity{}, _object} = CommonAPI.favorite(activity.id, user)
+ {:error, _} = CommonAPI.favorite(activity.id, user)
+ end
+ end
end