Files
danbooru/test/jobs/prune_bans_job_test.rb
evazion 52bf4a3a6b maintenance: break maintenance tasks into individual jobs.
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.
2021-09-26 20:38:30 -05:00

19 lines
559 B
Ruby

require 'test_helper'
class PruneBansJobTest < ActiveJob::TestCase
context "PruneBansJob" do
should "prune all expired bans" do
@expired_ban = travel_to(1.month.ago) { create(:ban, duration: 1.week) }
@unexpired_ban = create(:ban, duration: 1.week)
assert_equal(true, @expired_ban.user.is_banned?)
assert_equal(true, @unexpired_ban.user.is_banned?)
PruneBansJob.perform_now
assert_equal(false, @expired_ban.user.reload.is_banned?)
assert_equal(true, @unexpired_ban.user.reload.is_banned?)
end
end
end