diff options
author | lambda <pleromagit@rogerbraun.net> | 2017-11-12 09:24:32 +0000 |
---|---|---|
committer | lambda <pleromagit@rogerbraun.net> | 2017-11-12 09:24:32 +0000 |
commit | efcf54dc0248a7d37b1ecbe8a91d2340a2edaf6a (patch) | |
tree | bb638ee2cf00435ffc94f5ae6443c3ddf92f7a12 /test/web/mastodon_api | |
parent | 414c52509bfcd9a4f7f4a0eecadb714ab8d46f3a (diff) | |
parent | fc7483cb3c679040d40ea86f90384b097dcda2ca (diff) | |
download | pleroma-efcf54dc0248a7d37b1ecbe8a91d2340a2edaf6a.tar.gz |
Merge branch 'mastoapi-update-credentials' into 'develop'
MastoAPI: Add update credentials endpoint.
Closes #61
See merge request pleroma/pleroma!15
Diffstat (limited to 'test/web/mastodon_api')
-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 |