diff options
author | Alex Gleason <alex@alexgleason.me> | 2021-05-19 13:39:29 -0500 |
---|---|---|
committer | Alex Gleason <alex@alexgleason.me> | 2021-05-19 13:39:29 -0500 |
commit | e343b46ea041ce6a542b23100df2e9c11e262c75 (patch) | |
tree | 7bd219409244d97e51ad58f800889c65f41837a0 /test/pleroma/object_test.exs | |
parent | a5bbebda588a54cb76d1a75239523db676980eb0 (diff) | |
parent | 8e9f032f25251d910b59c55226d10a305bad3cba (diff) | |
download | pleroma-instance-view-recompilation.tar.gz |
Merge remote-tracking branch 'pleroma/develop' into instance-view-recompilationinstance-view-recompilation
Diffstat (limited to 'test/pleroma/object_test.exs')
-rw-r--r-- | test/pleroma/object_test.exs | 27 |
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 |