From 8e94936553c978e5f0d3bb802a1932a6b505f86e Mon Sep 17 00:00:00 2001 From: eal Date: Fri, 27 Oct 2017 13:55:36 +0300 Subject: Add tests. --- test/web/mastodon_api/mastodon_api_controller_test.exs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test') diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index 56888140d..af2351706 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -281,6 +281,13 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do |> post("/api/v1/accounts/#{other_user.id}/unfollow") assert %{"id" => id, "following" => false} = json_response(conn, 200) + + user = Repo.get(User, user.id) + conn = build_conn() + |> assign(:user, user) + |> post("/api/v1/follows", %{"uri" => other_user.nickname}) + + assert %{"id" => id, "following" => true} = json_response(conn, 200) end test "unimplemented block/mute endpoints" do -- cgit v1.2.3 From c56d28f96c343d445ec8d06baf351423691036f3 Mon Sep 17 00:00:00 2001 From: eal Date: Sun, 29 Oct 2017 00:07:38 +0300 Subject: Fix return type of /api/v1/follows --- test/web/mastodon_api/mastodon_api_controller_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index af2351706..4e5dc963f 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -287,7 +287,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do |> assign(:user, user) |> post("/api/v1/follows", %{"uri" => other_user.nickname}) - assert %{"id" => id, "following" => true} = json_response(conn, 200) + assert other_user = json_response(conn, 200) end test "unimplemented block/mute endpoints" do -- cgit v1.2.3 From 71f66bd4589faddc35137ed3197f685555b77aaf Mon Sep 17 00:00:00 2001 From: eal Date: Sun, 29 Oct 2017 14:25:11 +0200 Subject: Fix follow test semantics. --- test/web/mastodon_api/mastodon_api_controller_test.exs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index 4e5dc963f..acdb08ac2 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -287,7 +287,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do |> assign(:user, user) |> post("/api/v1/follows", %{"uri" => other_user.nickname}) - assert other_user = json_response(conn, 200) + assert %{"id" => id} = json_response(conn, 200) + assert id == other_user.id end test "unimplemented block/mute endpoints" do -- cgit v1.2.3 From 502cb38cd69f9f8c15a0ee597584364f9d36bdf1 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Mon, 30 Oct 2017 19:23:16 +0100 Subject: Move user search to User module. --- test/web/mastodon_api/mastodon_api_controller_test.exs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test') diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index acdb08ac2..485a0d029 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -319,6 +319,19 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do end) end + test "account seach", %{conn: conn} do + user = insert(:user) + user_two = insert(:user, %{nickname: "shp@shitposter.club"}) + user_three = insert(:user, %{nickname: "shp@heldscal.la", name: "I love 2hu"}) + + conn = conn + |> assign(:user, user) + |> get("/api/v1/accounts/search", %{"q" => "2hu"}) + + assert [account] = json_response(conn, 200) + assert account["id"] == user_three.id + end + test "search", %{conn: conn} do user = insert(:user) user_two = insert(:user, %{nickname: "shp@shitposter.club"}) -- cgit v1.2.3