2015-10-11 17:41:23 +08:00
|
|
|
require 'rails_helper'
|
2014-09-23 13:50:26 +08:00
|
|
|
|
|
|
|
require_dependency 'jobs/scheduled/clean_up_uploads'
|
|
|
|
|
|
|
|
describe Jobs::CleanUpUploads do
|
2016-06-21 04:05:41 +08:00
|
|
|
|
|
|
|
before do
|
|
|
|
Upload.destroy_all
|
2014-09-23 13:50:26 +08:00
|
|
|
SiteSetting.clean_up_uploads = true
|
2016-06-21 04:05:41 +08:00
|
|
|
SiteSetting.clean_orphan_uploads_grace_period_hours = 1
|
|
|
|
end
|
|
|
|
|
|
|
|
it "deletes orphan uploads" do
|
|
|
|
Fabricate(:upload, created_at: 2.hours.ago)
|
|
|
|
|
|
|
|
expect(Upload.count).to be(1)
|
|
|
|
|
2014-09-23 13:50:26 +08:00
|
|
|
Jobs::CleanUpUploads.new.execute(nil)
|
2016-06-21 04:05:41 +08:00
|
|
|
|
|
|
|
expect(Upload.count).to be(0)
|
2014-09-23 13:50:26 +08:00
|
|
|
end
|
2016-06-21 04:05:41 +08:00
|
|
|
|
2014-09-23 13:50:26 +08:00
|
|
|
end
|