mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 14:12:10 +08:00
FIX: log backups download/destroy staff action
FIX: clean up junk left by the specs RENAME: 'backup_operation' to 'backup_create' to match other backup log types
This commit is contained in:
@ -90,16 +90,18 @@ describe Admin::BackupsController do
|
||||
describe ".show" do
|
||||
|
||||
it "uses send_file to transmit the backup" do
|
||||
FileUtils.mkdir_p Backup.base_directory
|
||||
File.open(Backup.base_directory << "/" << backup_filename, "w") do |f|
|
||||
f.write("hello")
|
||||
end
|
||||
path = File.join(Backup.base_directory, backup_filename)
|
||||
File.open(path, "w") { |f| f.write("hello") }
|
||||
|
||||
Backup.create_from_filename(backup_filename)
|
||||
|
||||
StaffActionLogger.any_instance.expects(:log_backup_download).once
|
||||
|
||||
get :show, id: backup_filename
|
||||
|
||||
expect(response.headers['Content-Length']).to eq(5)
|
||||
File.delete(path) rescue nil
|
||||
|
||||
expect(response.headers['Content-Length']).to eq("5")
|
||||
expect(response.headers['Content-Disposition']).to match(/attachment; filename/)
|
||||
end
|
||||
|
||||
@ -120,7 +122,11 @@ describe Admin::BackupsController do
|
||||
it "removes the backup if found" do
|
||||
Backup.expects(:[]).with(backup_filename).returns(b)
|
||||
b.expects(:remove)
|
||||
|
||||
StaffActionLogger.any_instance.expects(:log_backup_destroy).with(b).once
|
||||
|
||||
xhr :delete, :destroy, id: backup_filename
|
||||
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
@ -223,8 +229,10 @@ describe Admin::BackupsController do
|
||||
it "should upload the file successfully" do
|
||||
described_class.any_instance.expects(:has_enough_space_on_disk?).returns(true)
|
||||
|
||||
filename = 'test_Site-0123456789.tar.gz'
|
||||
|
||||
xhr :post, :upload_backup_chunk,
|
||||
resumableFilename: 'test_Site-0123456789.tar.gz',
|
||||
resumableFilename: filename,
|
||||
resumableTotalSize: 1,
|
||||
resumableIdentifier: 'test',
|
||||
resumableChunkNumber: '1',
|
||||
@ -234,6 +242,8 @@ describe Admin::BackupsController do
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(response.body).to eq("")
|
||||
|
||||
File.delete(File.join(Backup.base_directory, filename)) rescue nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user