maintenance: consolidate maintenance tasks in logical/maintenance.rb.

This commit is contained in:
evazion
2018-10-07 22:22:45 -05:00
parent 1a4949368c
commit 5201954413
5 changed files with 23 additions and 31 deletions

View File

@@ -1,6 +1,6 @@
require 'test_helper'
class DailyMaintenanceTest < ActiveSupport::TestCase
class MaintenanceTest < ActiveSupport::TestCase
context "daily maintenance" do
setup do
# have ApiCacheGenerator save files to a temp dir.
@@ -17,14 +17,14 @@ class DailyMaintenanceTest < ActiveSupport::TestCase
end
should "work" do
assert_nothing_raised { DailyMaintenance.new.run }
assert_nothing_raised { Maintenance.daily }
end
should "prune expired posts" do
@pending = FactoryBot.create(:post, is_pending: true, created_at: 4.days.ago)
@flagged = FactoryBot.create(:post, is_flagged: true, created_at: 4.days.ago)
DailyMaintenance.new.run
Maintenance.daily
assert(true, @pending.reload.is_deleted)
assert(true, @flagged.reload.is_deleted)
@@ -38,7 +38,7 @@ class DailyMaintenanceTest < ActiveSupport::TestCase
CurrentUser.as(banner) { FactoryBot.create(:ban, user: user, banner: banner, duration: 1) }
assert_equal(true, user.reload.is_banned)
travel_to(2.days.from_now) { DailyMaintenance.new.run }
travel_to(2.days.from_now) { Maintenance.daily }
assert_equal(false, user.reload.is_banned)
end
end