Break the hourly/daily/weekly/monthly maintenance tasks down into individual delayed jobs. This way if one task fails, it won't prevent other tasks from running. Also, jobs can be run in parallel, and can be individually retried if they fail.
14 lines
339 B
Ruby
14 lines
339 B
Ruby
require 'test_helper'
|
|
|
|
class PruneRateLimitsJobTest < ActiveJob::TestCase
|
|
context "PruneRateLimitsJob" do
|
|
should "prune all stale rate limits" do
|
|
travel_to(2.hours.ago) { create(:rate_limit) }
|
|
|
|
assert_equal(1, RateLimit.count)
|
|
PruneRateLimitsJob.perform_now
|
|
assert_equal(0, RateLimit.count)
|
|
end
|
|
end
|
|
end
|