From 1555c66650967c5023b2a4f7a44a683d803091c6 Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Wed, 13 Jun 2018 21:29:55 -0400 Subject: Add unretweet TwAPI endpoint and cleanup AP.unannounce --- .../twitter_api/twitter_api_controller_test.exs | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'test/web/twitter_api/twitter_api_controller_test.exs') diff --git a/test/web/twitter_api/twitter_api_controller_test.exs b/test/web/twitter_api/twitter_api_controller_test.exs index 68f4331df..6866a362f 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/retweet/#{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 = %{ -- cgit v1.2.3 From fc15f30a3c53860af35eb39c6893428df966fb96 Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Wed, 13 Jun 2018 21:45:27 -0400 Subject: fixup test --- test/web/twitter_api/twitter_api_controller_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/web/twitter_api/twitter_api_controller_test.exs') diff --git a/test/web/twitter_api/twitter_api_controller_test.exs b/test/web/twitter_api/twitter_api_controller_test.exs index 6866a362f..197e35d13 100644 --- a/test/web/twitter_api/twitter_api_controller_test.exs +++ b/test/web/twitter_api/twitter_api_controller_test.exs @@ -585,7 +585,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do test "without valid credentials", %{conn: conn} do note_activity = insert(:note_activity) - conn = post(conn, "/api/statuses/retweet/#{note_activity.id}.json") + conn = post(conn, "/api/statuses/unretweet/#{note_activity.id}.json") assert json_response(conn, 403) == %{"error" => "Invalid credentials."} end -- cgit v1.2.3