Check if a refresh is permitted by comparing timestamps before attempting to insert an Oban job
It's better to avoid inserting an Oban job that will just be rejected if it's not expensive to check.
This commit is contained in:
parent
0a42a3f2ea
commit
ba2ae5e40b
3 changed files with 16 additions and 9 deletions
|
|
@ -29,13 +29,16 @@ defmodule Pleroma.Web.MastodonAPI.PollControllerTest do
|
|||
id = to_string(object.id)
|
||||
assert %{"id" => ^id, "expired" => false, "multiple" => false} = response
|
||||
|
||||
# Local activities should not generate an Oban job to refresh
|
||||
assert activity.local
|
||||
|
||||
refute_enqueued(
|
||||
worker: Pleroma.Workers.PollWorker,
|
||||
args: %{"op" => "refresh", "activity_id" => activity.id}
|
||||
)
|
||||
end
|
||||
|
||||
test "does not create oban job to refresh poll if activity is local", %{conn: conn} do
|
||||
test "creates an oban job to refresh poll if activity is remote", %{conn: conn} do
|
||||
user = insert(:user, local: false)
|
||||
question = insert(:question, user: user)
|
||||
activity = insert(:question_activity, question: question, local: false)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue