diff options
author | eal <eal@waifu.club> | 2017-11-12 00:27:09 +0200 |
---|---|---|
committer | eal <eal@waifu.club> | 2017-11-12 00:27:09 +0200 |
commit | fc7483cb3c679040d40ea86f90384b097dcda2ca (patch) | |
tree | 158ab65a36c02b69b459bd793345fc599f74d148 /test | |
parent | fd12e585c98d4cd2cca45f8ff2c368e80d21e111 (diff) | |
download | pleroma-fc7483cb3c679040d40ea86f90384b097dcda2ca.tar.gz |
MastoAPI: Add update credentials endpoint.
Diffstat (limited to 'test')
-rw-r--r-- | test/web/mastodon_api/mastodon_api_controller_test.exs | 50 |
1 files changed, 50 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 47a613837..cf60b4a51 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -420,4 +420,54 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do assert [status] = json_response(conn, 200) assert status["id"] == to_string(activity.id) end + + describe "updating credentials" do + test "updates the user's bio" do + user = insert(:user) + + conn = conn + |> assign(:user, user) + |> patch("/api/v1/accounts/update_credentials", %{"note" => "I drink #cofe"}) + + assert user = json_response(conn, 200) + assert user["note"] == "I drink #cofe" + end + + test "updates the user's name" do + user = insert(:user) + + conn = conn + |> assign(:user, user) + |> patch("/api/v1/accounts/update_credentials", %{"display_name" => "markorepairs"}) + + assert user = json_response(conn, 200) + assert user["display_name"] == "markorepairs" + end + + test "updates the user's avatar" do + user = insert(:user) + + new_avatar = %Plug.Upload{content_type: "image/jpg", path: Path.absname("test/fixtures/image.jpg"), filename: "an_image.jpg"} + + conn = conn + |> assign(:user, user) + |> patch("/api/v1/accounts/update_credentials", %{"avatar" => new_avatar}) + + assert user = json_response(conn, 200) + assert user["avatar"] != "https://placehold.it/48x48" + end + + test "updates the user's banner" do + user = insert(:user) + + new_header = %Plug.Upload{content_type: "image/jpg", path: Path.absname("test/fixtures/image.jpg"), filename: "an_image.jpg"} + + conn = conn + |> assign(:user, user) + |> patch("/api/v1/accounts/update_credentials", %{"header" => new_header}) + + assert user = json_response(conn, 200) + assert user["header"] != "https://placehold.it/700x335" + end + end end |