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:
@@ -1,4 +1,4 @@
|
|||||||
module Maintenance
|
module DanbooruMaintenance
|
||||||
module_function
|
module_function
|
||||||
|
|
||||||
def hourly
|
def hourly
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
Reference in New Issue
Block a user