Merge branch 'develop' of https://git.pleroma.social/pleroma/pleroma into develop
[akkoma] / test / web / mastodon_api / status_view_test.exs
index a02c7c21049edb73a25d60653d239b3343cf162f..5fddc6c58bbcad6cc44e70addfbd701965f3d670 100644 (file)
@@ -6,6 +6,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
   use Pleroma.DataCase
 
   alias Pleroma.Activity
+  alias Pleroma.Bookmark
   alias Pleroma.Object
   alias Pleroma.Repo
   alias Pleroma.User
@@ -128,6 +129,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
       pleroma: %{
         local: true,
         conversation_id: convo_id,
+        in_reply_to_account_acct: nil,
         content: %{"text/plain" => HtmlSanitizeEx.strip_tags(note.data["object"]["content"])},
         spoiler_text: %{"text/plain" => HtmlSanitizeEx.strip_tags(note.data["object"]["summary"])}
       }
@@ -152,6 +154,25 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
     assert status.muted == true
   end
 
+  test "tells if the status is bookmarked" do
+    user = insert(:user)
+
+    {:ok, activity} = CommonAPI.post(user, %{"status" => "Cute girls doing cute things"})
+    status = StatusView.render("status.json", %{activity: activity})
+
+    assert status.bookmarked == false
+
+    status = StatusView.render("status.json", %{activity: activity, for: user})
+
+    assert status.bookmarked == false
+
+    {:ok, _bookmark} = Bookmark.create(user.id, activity.id)
+
+    status = StatusView.render("status.json", %{activity: activity, for: user})
+
+    assert status.bookmarked == true
+  end
+
   test "a reply" do
     note = insert(:note_activity)
     user = insert(:user)
@@ -178,7 +199,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
 
     status = StatusView.render("status.json", %{activity: activity})
 
-    actor = User.get_by_ap_id(activity.actor)
+    actor = User.get_cached_by_ap_id(activity.actor)
 
     assert status.mentions ==
              Enum.map([user, actor], fn u -> AccountView.render("mention.json", %{user: u}) end)