From c731f0f084577356ca813a4537fe0c888fbb8aad Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 21 Nov 2023 17:29:58 +0100 Subject: [PATCH] test: fix tests Signed-off-by: Thomas Citharel --- lib/mobilizon/posts/posts.ex | 11 +++++---- lib/service/export/icalendar.ex | 2 +- .../transmogrifier/posts_test.exs | 3 --- .../workers/legacy_notifier_builder_test.exs | 23 ++++++++++--------- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/lib/mobilizon/posts/posts.ex b/lib/mobilizon/posts/posts.ex index 9bd54198f..5fe60b433 100644 --- a/lib/mobilizon/posts/posts.ex +++ b/lib/mobilizon/posts/posts.ex @@ -110,10 +110,13 @@ defmodule Mobilizon.Posts do def update_post(%Post{} = post, attrs) do Cachable.clear_all_caches(post) - post - |> Repo.preload([:tags, :media]) - |> Post.changeset(attrs) - |> Repo.update() + with {:ok, %Post{} = post} <- + post + |> Repo.preload(@post_preloads) + |> Post.changeset(attrs) + |> Repo.update() do + {:ok, Repo.preload(post, @post_preloads)} + end end @doc """ diff --git a/lib/service/export/icalendar.ex b/lib/service/export/icalendar.ex index 0fa8032ab..9d89e9547 100644 --- a/lib/service/export/icalendar.ex +++ b/lib/service/export/icalendar.ex @@ -8,7 +8,7 @@ defmodule Mobilizon.Service.Export.ICalendar do alias Mobilizon.{Config, Events} alias Mobilizon.Events.{Event, EventOptions} alias Mobilizon.Service.Export.{Cachable, Common} - alias Mobilizon.Service.Formatter.{HTML, Text} + alias Mobilizon.Service.Formatter.HTML @behaviour Cachable diff --git a/test/federation/activity_pub/transmogrifier/posts_test.exs b/test/federation/activity_pub/transmogrifier/posts_test.exs index c79b01a0a..6613324c3 100644 --- a/test/federation/activity_pub/transmogrifier/posts_test.exs +++ b/test/federation/activity_pub/transmogrifier/posts_test.exs @@ -2,15 +2,12 @@ defmodule Mobilizon.Federation.ActivityPub.Transmogrifier.PostsTest do use Mobilizon.DataCase import Mobilizon.Factory - import Mox alias Mobilizon.Actors.Actor alias Mobilizon.Federation.ActivityPub.{Activity, Transmogrifier} alias Mobilizon.Federation.ActivityStream.Convertible alias Mobilizon.Posts.Post describe "handle incoming posts" do - setup :verify_on_exit! - test "it ignores an incoming post if we already have it" do post = insert(:post) post = Repo.preload(post, [:author, :attributed_to, :picture, :media]) diff --git a/test/service/workers/legacy_notifier_builder_test.exs b/test/service/workers/legacy_notifier_builder_test.exs index 2a079ab07..a54a8ea9d 100644 --- a/test/service/workers/legacy_notifier_builder_test.exs +++ b/test/service/workers/legacy_notifier_builder_test.exs @@ -187,17 +187,18 @@ defmodule Mobilizon.Service.Workers.LegacyNotifierBuilderTest do "object_id" => to_string(comment_id) }) - NotifierMock - |> expect(:ready?, fn -> true end) - |> expect(:send, fn %User{}, - %Activity{ - type: :comment, - subject: :participation_event_comment, - object_type: :comment - }, - [single_activity: true] -> - {:ok, :sent} - end) + # # Disabled as announcement is sent straight away + # NotifierMock + # |> expect(:ready?, fn -> true end) + # |> expect(:send, fn %User{}, + # %Activity{ + # type: :comment, + # subject: :participation_event_comment, + # object_type: :comment + # }, + # [single_activity: true] -> + # {:ok, :sent} + # end) assert :ok == LegacyNotifierBuilder.perform(%Oban.Job{args: args}) end