From 634e3d4155df4c327d608a112fd4a3caf44cf9b8 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Sun, 23 Jun 2024 20:56:58 -0400 Subject: [PATCH] Add test validating the activity_id is correctly present in the Oban job This was preventing the activity from being streamed over websockets. --- changelog.d/rich_media_oban.skip | 0 lib/pleroma/web/rich_media/card.ex | 2 +- test/pleroma/web/rich_media/card_test.exs | 7 +++++++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 changelog.d/rich_media_oban.skip diff --git a/changelog.d/rich_media_oban.skip b/changelog.d/rich_media_oban.skip new file mode 100644 index 000000000..e69de29bb diff --git a/lib/pleroma/web/rich_media/card.ex b/lib/pleroma/web/rich_media/card.ex index 72ff5e791..abad4957e 100644 --- a/lib/pleroma/web/rich_media/card.ex +++ b/lib/pleroma/web/rich_media/card.ex @@ -83,7 +83,7 @@ defmodule Pleroma.Web.RichMedia.Card do card nil -> - activity_id = Keyword.get(opts, :activity, nil) + activity_id = Keyword.get(opts, :activity_id, nil) RichMediaWorker.new(%{"op" => "backfill", "url" => url, "activity_id" => activity_id}) |> Oban.insert() diff --git a/test/pleroma/web/rich_media/card_test.exs b/test/pleroma/web/rich_media/card_test.exs index c76df99e2..33d07127f 100644 --- a/test/pleroma/web/rich_media/card_test.exs +++ b/test/pleroma/web/rich_media/card_test.exs @@ -3,12 +3,14 @@ # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.RichMedia.CardTest do + use Oban.Testing, repo: Pleroma.Repo use Pleroma.DataCase, async: true alias Pleroma.Tests.ObanHelpers alias Pleroma.UnstubbedConfigMock, as: ConfigMock alias Pleroma.Web.CommonAPI alias Pleroma.Web.RichMedia.Card + alias Pleroma.Workers.RichMediaWorker import Mox import Pleroma.Factory @@ -37,6 +39,11 @@ defmodule Pleroma.Web.RichMedia.CardTest do content_type: "text/markdown" }) + assert_enqueued( + worker: RichMediaWorker, + args: %{"url" => url, "activity_id" => activity.id} + ) + ObanHelpers.perform_all() assert %Card{url_hash: ^url_hash, fields: _} = Card.get_by_activity(activity)