UserController: fall back to frontend when user isn't found

This commit is contained in:
Alex Gleason 2021-08-17 18:32:32 -05:00
commit b11dbbf403
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
2 changed files with 18 additions and 3 deletions

View file

@ -196,13 +196,26 @@ defmodule Pleroma.Web.Feed.UserControllerTest do
).resp_body
end
test "with html format, it returns error when user is not found", %{conn: conn} do
test "with html format, it falls back to frontend when user is remote", %{conn: conn} do
user = insert(:user, local: false)
{:ok, _} = CommonAPI.post(user, %{status: "test"})
response =
conn
|> get("/users/#{user.nickname}")
|> response(200)
assert response =~ "</html>"
end
test "with html format, it falls back to frontend when user is not found", %{conn: conn} do
response =
conn
|> get("/users/jimm")
|> json_response(404)
|> response(200)
assert response == %{"error" => "Not found"}
assert response =~ "</html>"
end
test "with non-html / non-json format, it redirects to user feed in atom format", %{