diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/web/mastodon_api/status_view_test.exs | 30 | 
1 files changed, 30 insertions, 0 deletions
| diff --git a/test/web/mastodon_api/status_view_test.exs b/test/web/mastodon_api/status_view_test.exs index 1076b5002..d30ae6149 100644 --- a/test/web/mastodon_api/status_view_test.exs +++ b/test/web/mastodon_api/status_view_test.exs @@ -19,6 +19,36 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do      :ok    end +  test "returns a temporary ap_id based user for activities missing db users" do +    user = insert(:user) + +    {:ok, activity} = CommonAPI.post(user, %{"status" => "Hey @shp!", "visibility" => "direct"}) + +    Repo.delete(user) +    Cachex.clear(:user_cache) + +    %{account: ms_user} = StatusView.render("status.json", activity: activity) + +    assert ms_user.acct == "erroruser@example.com" +  end + +  test "tries to get a user by nickname if fetching by ap_id doesn't work" do +    user = insert(:user) + +    {:ok, activity} = CommonAPI.post(user, %{"status" => "Hey @shp!", "visibility" => "direct"}) + +    {:ok, user} = +      user +      |> Ecto.Changeset.change(%{ap_id: "#{user.ap_id}/extension/#{user.nickname}"}) +      |> Repo.update() + +    Cachex.clear(:user_cache) + +    result = StatusView.render("status.json", activity: activity) + +    assert result[:account][:id] == to_string(user.id) +  end +    test "a note with null content" do      note = insert(:note_activity) | 
