Rename maintenance.rb -> danbooru_maintenance.rb.

Fixes random test failures caused by ambiguous constant lookup issues
(the `Maintenance` module name was used in multiple conflicting places).
This commit is contained in:
evazion
2019-08-15 00:36:25 -05:00
parent 247d825618
commit 5f1226ca92
3 changed files with 8 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
module Maintenance
module DanbooruMaintenance
module_function
def hourly

View File

@@ -3,16 +3,16 @@ require "tasks/newrelic" if defined?(NewRelic)
namespace :maintenance do
desc "Run hourly maintenance jobs"
task hourly: :environment do
Maintenance.hourly
DanbooruMaintenance.hourly
end
desc "Run daily maintenance jobs"
task daily: :environment do
Maintenance.daily
DanbooruMaintenance.daily
end
desc "Run weekly maintenance jobs"
task weekly: :environment do
Maintenance.weekly
DanbooruMaintenance.weekly
end
end

View File

@@ -1,6 +1,6 @@
require 'test_helper'
class MaintenanceTest < ActiveSupport::TestCase
class DanbooruMaintenanceTest < ActiveSupport::TestCase
context "daily maintenance" do
setup do
# have ApiCacheGenerator save files to a temp dir.
@@ -17,14 +17,14 @@ class MaintenanceTest < ActiveSupport::TestCase
end
should "work" do
assert_nothing_raised { Maintenance.daily }
assert_nothing_raised { DanbooruMaintenance.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)
Maintenance.daily
DanbooruMaintenance.daily
assert(true, @pending.reload.is_deleted)
assert(true, @flagged.reload.is_deleted)
@@ -38,7 +38,7 @@ class MaintenanceTest < 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) { Maintenance.daily }
travel_to(2.days.from_now) { DanbooruMaintenance.daily }
assert_equal(false, user.reload.is_banned)
end
end