aboutsummaryrefslogtreecommitdiff
path: root/test/web/twitter_api/twitter_api_controller_test.exs
diff options
context:
space:
mode:
authorlambda <pleromagit@rogerbraun.net>2018-06-14 07:19:36 +0000
committerlambda <pleromagit@rogerbraun.net>2018-06-14 07:19:36 +0000
commit8c7fdcb31b1255f91493b8f2e0f86dfbbfa2ac85 (patch)
tree6bafa899d5e5ac3696ae1d05c1746e134c5898b9 /test/web/twitter_api/twitter_api_controller_test.exs
parent2c303b3302e28a85aec448a9d57f9c5b1e658bfb (diff)
parentfc15f30a3c53860af35eb39c6893428df966fb96 (diff)
downloadpleroma-8c7fdcb31b1255f91493b8f2e0f86dfbbfa2ac85.tar.gz
Merge branch 'feature/twitterapi-unrepeat' into 'develop'
Add TwitterAPI unretweet endpoint and cleanup AP.unannounce See merge request pleroma/pleroma!218
Diffstat (limited to 'test/web/twitter_api/twitter_api_controller_test.exs')
-rw-r--r--test/web/twitter_api/twitter_api_controller_test.exs34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/web/twitter_api/twitter_api_controller_test.exs b/test/web/twitter_api/twitter_api_controller_test.exs
index bd11551df..806227110 100644
--- a/test/web/twitter_api/twitter_api_controller_test.exs
+++ b/test/web/twitter_api/twitter_api_controller_test.exs
@@ -580,6 +580,40 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
end
end
+ describe "POST /api/statuses/unretweet/:id" do
+ setup [:valid_user]
+
+ test "without valid credentials", %{conn: conn} do
+ note_activity = insert(:note_activity)
+ conn = post(conn, "/api/statuses/unretweet/#{note_activity.id}.json")
+ assert json_response(conn, 403) == %{"error" => "Invalid credentials."}
+ end
+
+ test "with credentials", %{conn: conn, user: current_user} do
+ note_activity = insert(:note_activity)
+
+ request_path = "/api/statuses/retweet/#{note_activity.id}.json"
+
+ _response =
+ conn
+ |> with_credentials(current_user.nickname, "test")
+ |> post(request_path)
+
+ request_path = String.replace(request_path, "retweet", "unretweet")
+
+ response =
+ conn
+ |> with_credentials(current_user.nickname, "test")
+ |> post(request_path)
+
+ activity = Repo.get(Activity, note_activity.id)
+ activity_user = Repo.get_by(User, ap_id: note_activity.data["actor"])
+
+ assert json_response(response, 200) ==
+ ActivityRepresenter.to_map(activity, %{user: activity_user, for: current_user})
+ end
+ end
+
describe "POST /api/account/register" do
test "it creates a new user", %{conn: conn} do
data = %{