Merge branch 'avatar-removing' into 'develop'

UpdateCredentialsTest: Add test for removing profile images.

See merge request pleroma/pleroma!2701
This commit is contained in:
lain 2020-06-29 11:16:30 +00:00
commit 651f269568
1 changed files with 40 additions and 7 deletions

View File

@ -216,10 +216,20 @@ test "updates the user's avatar", %{user: user, conn: conn} do
filename: "an_image.jpg" filename: "an_image.jpg"
} }
conn = patch(conn, "/api/v1/accounts/update_credentials", %{"avatar" => new_avatar}) res =
conn
|> patch("/api/v1/accounts/update_credentials", %{"avatar" => new_avatar})
assert user_response = json_response_and_validate_schema(conn, 200) assert user_response = json_response_and_validate_schema(res, 200)
assert user_response["avatar"] != User.avatar_url(user) assert user_response["avatar"] != User.avatar_url(user)
# Also removes it
res =
conn
|> patch("/api/v1/accounts/update_credentials", %{"avatar" => nil})
assert user_response = json_response_and_validate_schema(res, 200)
assert user_response["avatar"] == User.avatar_url(user)
end end
test "updates the user's banner", %{user: user, conn: conn} do test "updates the user's banner", %{user: user, conn: conn} do
@ -229,10 +239,21 @@ test "updates the user's banner", %{user: user, conn: conn} do
filename: "an_image.jpg" filename: "an_image.jpg"
} }
conn = patch(conn, "/api/v1/accounts/update_credentials", %{"header" => new_header}) res =
conn
|> patch("/api/v1/accounts/update_credentials", %{"header" => new_header})
assert user_response = json_response_and_validate_schema(conn, 200) assert user_response = json_response_and_validate_schema(res, 200)
assert user_response["header"] != User.banner_url(user) assert user_response["header"] != User.banner_url(user)
# Also removes it
res =
conn
|> patch("/api/v1/accounts/update_credentials", %{"header" => nil})
assert user_response = json_response_and_validate_schema(res, 200)
assert user_response["header"] == User.banner_url(user)
end end
test "updates the user's background", %{conn: conn} do test "updates the user's background", %{conn: conn} do
@ -242,13 +263,25 @@ test "updates the user's background", %{conn: conn} do
filename: "an_image.jpg" filename: "an_image.jpg"
} }
conn = res =
patch(conn, "/api/v1/accounts/update_credentials", %{ conn
|> patch("/api/v1/accounts/update_credentials", %{
"pleroma_background_image" => new_header "pleroma_background_image" => new_header
}) })
assert user_response = json_response_and_validate_schema(conn, 200) assert user_response = json_response_and_validate_schema(res, 200)
assert user_response["pleroma"]["background_image"] assert user_response["pleroma"]["background_image"]
# Also removes it
res =
conn
|> patch("/api/v1/accounts/update_credentials", %{
"pleroma_background_image" => nil
})
assert user_response = json_response_and_validate_schema(res, 200)
refute user_response["pleroma"]["background_image"]
end end
test "requires 'write:accounts' permission" do test "requires 'write:accounts' permission" do