mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 23:31:18 +08:00
Support for removal of old backups automatically via a site setting
This commit is contained in:
@ -36,7 +36,6 @@ describe Admin::BackupsController do
|
||||
context "json format" do
|
||||
|
||||
it "returns a list of all the backups" do
|
||||
File.stubs(:size).returns(42)
|
||||
Backup.expects(:all).returns([Backup.new("backup1"), Backup.new("backup2")])
|
||||
|
||||
xhr :get, :index, format: :json
|
||||
@ -104,9 +103,7 @@ describe Admin::BackupsController do
|
||||
it "uses send_file to transmit the backup" do
|
||||
controller.stubs(:render) # we need this since we're stubing send_file
|
||||
|
||||
File.stubs(:size).returns(42)
|
||||
backup = Backup.new("backup42")
|
||||
|
||||
Backup.expects(:[]).with(backup_filename).returns(backup)
|
||||
subject.expects(:send_file).with(backup.path)
|
||||
|
||||
@ -125,14 +122,22 @@ describe Admin::BackupsController do
|
||||
|
||||
describe ".destroy" do
|
||||
|
||||
it "removes the backup" do
|
||||
Backup.expects(:remove).with(backup_filename)
|
||||
let(:b) { Backup.new(backup_filename) }
|
||||
|
||||
it "removes the backup if found" do
|
||||
Backup.expects(:[]).with(backup_filename).returns(b)
|
||||
b.expects(:remove)
|
||||
xhr :delete, :destroy, id: backup_filename
|
||||
|
||||
response.should be_success
|
||||
end
|
||||
|
||||
it "doesn't remove the backup if not found" do
|
||||
Backup.expects(:[]).with(backup_filename).returns(nil)
|
||||
b.expects(:remove).never
|
||||
xhr :delete, :destroy, id: backup_filename
|
||||
response.should_not be_success
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe ".logs" do
|
||||
|
Reference in New Issue
Block a user