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 module_function
def hourly def hourly

View File

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

View File

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