tests: add tests for /api/pleroma/friend_requests
authorWilliam Pitcock <nenolod@dereferenced.org>
Wed, 6 Jun 2018 23:46:55 +0000 (23:46 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Mon, 11 Jun 2018 22:15:53 +0000 (22:15 +0000)
test/web/twitter_api/twitter_api_controller_test.exs

index 6a29d583c87c961d4cd43d47d210f31a3b6426ca..ac8ccfbc3876c5a2187a73ab2d5db10a78958db9 100644 (file)
@@ -958,4 +958,26 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
       :timer.sleep(1000)
     end
   end
+
+  describe "GET /api/pleroma/friend_requests" do
+    test "it lists friend requests" do
+      user = insert(:user, %{info: %{"locked" => true}})
+      other_user = insert(:user)
+
+      {:ok, activity} = ActivityPub.follow(other_user, user)
+
+      user = Repo.get(User, user.id)
+      other_user = Repo.get(User, other_user.id)
+
+      assert User.following?(other_user, user) == false
+
+      conn =
+        build_conn()
+        |> assign(:user, user)
+        |> get("/api/pleroma/friend_requests")
+
+      assert [relationship] = json_response(conn, 200)
+      assert other_user.id == relationship["id"]
+    end
+  end
 end