aboutsummaryrefslogtreecommitdiff
path: root/test/pleroma/object_test.exs
diff options
context:
space:
mode:
authorAlex Gleason <alex@alexgleason.me>2021-05-28 13:38:44 -0500
committerAlex Gleason <alex@alexgleason.me>2021-05-28 13:38:44 -0500
commit05b47aacd25a86ba6dfcdd6577c6c558229c8e95 (patch)
treee4ecd6498fc64a78bf8d92c2ca6e8f8edc0fbcfe /test/pleroma/object_test.exs
parent9b0b0842ce2b0b9a870f57e16025160855aa4c11 (diff)
parent7ad87571bdcd39959280d15f5bfe4175e04c442c (diff)
downloadpleroma-endpoint-url.tar.gz
Merge remote-tracking branch 'pleroma/develop' into endpoint-urlendpoint-url
Diffstat (limited to 'test/pleroma/object_test.exs')
-rw-r--r--test/pleroma/object_test.exs27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/pleroma/object_test.exs b/test/pleroma/object_test.exs
index db7678d5d..8320660a5 100644
--- a/test/pleroma/object_test.exs
+++ b/test/pleroma/object_test.exs
@@ -5,10 +5,13 @@
defmodule Pleroma.ObjectTest do
use Pleroma.DataCase
use Oban.Testing, repo: Pleroma.Repo
+
import ExUnit.CaptureLog
import Pleroma.Factory
import Tesla.Mock
+
alias Pleroma.Activity
+ alias Pleroma.Hashtag
alias Pleroma.Object
alias Pleroma.Repo
alias Pleroma.Tests.ObanHelpers
@@ -417,4 +420,28 @@ defmodule Pleroma.ObjectTest do
assert updated_object.data["like_count"] == 1
end
end
+
+ describe ":hashtags association" do
+ test "Hashtag records are created with Object record and updated on its change" do
+ user = insert(:user)
+
+ {:ok, %{object: object}} =
+ CommonAPI.post(user, %{status: "some text #hashtag1 #hashtag2 ..."})
+
+ assert [%Hashtag{name: "hashtag1"}, %Hashtag{name: "hashtag2"}] =
+ Enum.sort_by(object.hashtags, & &1.name)
+
+ {:ok, object} = Object.update_data(object, %{"tag" => []})
+
+ assert [] = object.hashtags
+
+ object = Object.get_by_id(object.id) |> Repo.preload(:hashtags)
+ assert [] = object.hashtags
+
+ {:ok, object} = Object.update_data(object, %{"tag" => ["abc", "def"]})
+
+ assert [%Hashtag{name: "abc"}, %Hashtag{name: "def"}] =
+ Enum.sort_by(object.hashtags, & &1.name)
+ end
+ end
end