diff options
Diffstat (limited to 'test/web/twitter_api/twitter_api_controller_test.exs')
-rw-r--r-- | test/web/twitter_api/twitter_api_controller_test.exs | 23 |
1 files changed, 23 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 a504393be..b0a0cdb54 100644 --- a/test/web/twitter_api/twitter_api_controller_test.exs +++ b/test/web/twitter_api/twitter_api_controller_test.exs @@ -99,6 +99,29 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do end end + describe "POST /friendships/destroy.json" do + setup [:valid_user] + test "without valid credentials", %{conn: conn} do + conn = post conn, "/api/friendships/destroy.json" + assert json_response(conn, 403) == %{"error" => "Invalid credentials."} + end + + test "with credentials", %{conn: conn, user: current_user} do + {:ok, followed } = UserBuilder.insert(%{name: "some guy"}) + + {:ok, current_user} = User.follow(current_user, followed) + assert current_user.following == [User.ap_followers(followed)] + + conn = conn + |> with_credentials(current_user.nickname, "test") + |> post("/api/friendships/destroy.json", %{user_id: followed.id}) + + current_user = Repo.get(User, current_user.id) + assert current_user.following == [] + assert json_response(conn, 200) == UserRepresenter.to_map(followed) + end + end + defp valid_user(_context) do { :ok, user } = UserBuilder.insert(%{nickname: "lambda", ap_id: "lambda"}) [user: user] |