diff options
author | Roger Braun <rbraun@Bobble.local> | 2017-09-14 18:30:05 +0200 |
---|---|---|
committer | Roger Braun <rbraun@Bobble.local> | 2017-09-14 18:30:05 +0200 |
commit | 3ca853fb6165b82c39f23e24783e813015db48d5 (patch) | |
tree | bf322c2fe0242c42d9323601ab47f88f15d46571 /test/web/mastodon_api | |
parent | fc85c9f086cd5dd73effa28cb68fb245a554fa98 (diff) | |
download | pleroma-3ca853fb6165b82c39f23e24783e813015db48d5.tar.gz |
MastoAPI: Follower-related changes
Diffstat (limited to 'test/web/mastodon_api')
-rw-r--r-- | test/web/mastodon_api/mastodon_api_controller_test.exs | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index 25b4f2b37..1b887cc24 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -240,4 +240,74 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do assert id == activity.id end + + test "getting followers", %{conn: conn} do + user = insert(:user) + other_user = insert(:user) + {:ok, user} = User.follow(user, other_user) + + conn = conn + |> get("/api/v1/accounts/#{other_user.id}/followers") + + assert [%{"id" => id}] = json_response(conn, 200) + assert id = user.id + end + + test "getting following", %{conn: conn} do + user = insert(:user) + other_user = insert(:user) + {:ok, user} = User.follow(user, other_user) + + conn = conn + |> get("/api/v1/accounts/#{user.id}/following") + + assert [%{"id" => id}] = json_response(conn, 200) + assert id = other_user.id + end + + test "following / unfollowing a user", %{conn: conn} do + user = insert(:user) + other_user = insert(:user) + + conn = conn + |> assign(:user, user) + |> post("/api/v1/accounts/#{other_user.id}/follow") + + assert %{"id" => id, "following" => true} = json_response(conn, 200) + + user = Repo.get(User, user.id) + conn = build_conn() + |> assign(:user, user) + |> post("/api/v1/accounts/#{other_user.id}/unfollow") + + assert %{"id" => id, "following" => false} = json_response(conn, 200) + end + + test "unimplemented block/mute endpoints" do + user = insert(:user) + other_user = insert(:user) + + ["block", "unblock", "mute", "unmute"] + |> Enum.each(fn(endpoint) -> + conn = build_conn() + |> assign(:user, user) + |> post("/api/v1/accounts/#{other_user.id}/#{endpoint}") + + assert %{"id" => id} = json_response(conn, 200) + assert id == other_user.id + end) + end + + test "unimplemented mutes, follow_requests, blocks, domain blocks" do + user = insert(:user) + + ["blocks", "domain_blocks", "mutes", "follow_requests"] + |> Enum.each(fn(endpoint) -> + conn = build_conn() + |> assign(:user, user) + |> get("/api/v1/#{endpoint}") + + assert [] = json_response(conn, 200) + end) + end end |