discourse/spec/jobs/clean_up_uploads_spec.rb

24 lines
459 B
Ruby
Raw Normal View History

require 'rails_helper'
require_dependency 'jobs/scheduled/clean_up_uploads'
describe Jobs::CleanUpUploads do
2016-06-20 16:05:41 -04:00
before do
Upload.destroy_all
SiteSetting.clean_up_uploads = true
2016-06-20 16:05:41 -04: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)
Jobs::CleanUpUploads.new.execute(nil)
2016-06-20 16:05:41 -04:00
expect(Upload.count).to be(0)
end
2016-06-20 16:05:41 -04:00
end