From be8f367b0603496f2fd9b2a7bc97ca1e8866cbfd Mon Sep 17 00:00:00 2001 From: Rosa Gutierrez Date: Fri, 29 Nov 2024 14:46:46 +0100 Subject: [PATCH] Delete missing static recurring tasks before loading them again Closes #382 and #420. --- lib/solid_queue/scheduler/recurring_schedule.rb | 1 + test/integration/recurring_tasks_test.rb | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/solid_queue/scheduler/recurring_schedule.rb b/lib/solid_queue/scheduler/recurring_schedule.rb index 5b8ff6bb..4070a0ec 100644 --- a/lib/solid_queue/scheduler/recurring_schedule.rb +++ b/lib/solid_queue/scheduler/recurring_schedule.rb @@ -41,6 +41,7 @@ def task_keys private def persist_tasks + SolidQueue::RecurringTask.static.where.not(key: task_keys).delete_all SolidQueue::RecurringTask.create_or_update_all configured_tasks end diff --git a/test/integration/recurring_tasks_test.rb b/test/integration/recurring_tasks_test.rb index aa48c12a..7367bc06 100644 --- a/test/integration/recurring_tasks_test.rb +++ b/test/integration/recurring_tasks_test.rb @@ -64,13 +64,13 @@ class RecurringTasksTest < ActiveSupport::TestCase scheduler1 = SolidQueue::Scheduler.new(recurring_tasks: another_task).tap(&:start) wait_for_registered_processes(6, timeout: 1.second) - assert_recurring_tasks configured_task.merge(another_task) + assert_recurring_tasks another_task updated_task = { example_task: { class: "AddToBufferJob", schedule: "every minute" } } scheduler2 = SolidQueue::Scheduler.new(recurring_tasks: updated_task).tap(&:start) wait_for_registered_processes(7, timeout: 1.second) - assert_recurring_tasks configured_task.merge(updated_task) + assert_recurring_tasks updated_task terminate_process(@pid) scheduler1.stop