Merge pull request #3951 from evazion/fix-maintenance-logging

Improve daily maintenance error handling
This commit is contained in:
Albert Yi
2018-10-15 14:20:44 -07:00
committed by GitHub
8 changed files with 123 additions and 50 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