Add crono rake tasks spec

This commit is contained in:
Dzmitry Plashchynski
2015-03-17 18:28:17 +02:00
parent 7328bea24c
commit dc70212f9d
2 changed files with 21 additions and 1 deletions

View File

@@ -1,8 +1,14 @@
module Crono
def self.load_cronotab
require File.join(Rails.root, Config::CRONOTAB)
end
end
namespace :crono do
desc 'Clean unused job stats from DB'
task clean: :environment do
Crono.scheduler = Crono::Scheduler.new
require File.join(Rails.root, 'config', 'cronotab')
Crono.load_cronotab
current_job_ids = Crono.scheduler.jobs.map(&:job_id)
Crono::CronoJob.where.not(job_id: current_job_ids).destroy_all
end