diff options
author | Roger Braun <roger@rogerbraun.net> | 2017-03-22 18:36:08 +0100 |
---|---|---|
committer | Roger Braun <roger@rogerbraun.net> | 2017-03-23 12:09:27 +0100 |
commit | 75e51b190d5b4bd4e9cbf6a669bfce7a440e1a5c (patch) | |
tree | 4a0d15872d1fcd8ae64dacd9508e0c3a09aea502 /test/web/twitter_api/twitter_api_controller_test.exs | |
parent | e2e0cd75b77778cb7adf911cf279d0ccc008dab1 (diff) | |
download | pleroma-75e51b190d5b4bd4e9cbf6a669bfce7a440e1a5c.tar.gz |
Add following TwAPI endpoint.
Diffstat (limited to 'test/web/twitter_api/twitter_api_controller_test.exs')
-rw-r--r-- | test/web/twitter_api/twitter_api_controller_test.exs | 20 |
1 files changed, 20 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 86c03c652..a504393be 100644 --- a/test/web/twitter_api/twitter_api_controller_test.exs +++ b/test/web/twitter_api/twitter_api_controller_test.exs @@ -79,6 +79,26 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do end end + describe "POST /friendships/create.json" do + setup [:valid_user] + test "without valid credentials", %{conn: conn} do + conn = post conn, "/api/friendships/create.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"}) + + conn = conn + |> with_credentials(current_user.nickname, "test") + |> post("/api/friendships/create.json", %{user_id: followed.id}) + + current_user = Repo.get(User, current_user.id) + assert current_user.following == [User.ap_followers(followed)] + 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] |