mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 19:34:09 +08:00
89ad2b5900
This updates tests to use latest rails 5 practice and updates ALL dependencies that could be updated Performance testing shows that performance has not regressed if anything it is marginally faster now.
73 lines
1.7 KiB
Ruby
73 lines
1.7 KiB
Ruby
require 'rails_helper'
|
|
|
|
RSpec.describe Admin::BackupsController do
|
|
let(:admin) { Fabricate(:admin) }
|
|
|
|
before do
|
|
sign_in(admin)
|
|
end
|
|
|
|
describe "#index" do
|
|
it "raises an error when backups are disabled" do
|
|
SiteSetting.enable_backups = false
|
|
get "/admin/backups.json"
|
|
expect(response).not_to be_successful
|
|
end
|
|
end
|
|
|
|
describe '#rollback' do
|
|
it 'should rollback the restore' do
|
|
BackupRestore.expects(:rollback!)
|
|
|
|
post "/admin/backups/rollback.json"
|
|
|
|
expect(response).to be_successful
|
|
end
|
|
|
|
it 'should not allow rollback via a GET request' do
|
|
get "/admin/backups/rollback.json"
|
|
expect(response.status).to eq(404)
|
|
end
|
|
end
|
|
|
|
describe '#cancel' do
|
|
it "should cancel an backup" do
|
|
BackupRestore.expects(:cancel!)
|
|
|
|
delete "/admin/backups/cancel.json"
|
|
|
|
expect(response).to be_successful
|
|
end
|
|
|
|
it 'should not allow cancel via a GET request' do
|
|
get "/admin/backups/cancel.json"
|
|
expect(response.status).to eq(404)
|
|
end
|
|
end
|
|
|
|
describe "#email" do
|
|
let(:backup_filename) { "test.tar.gz" }
|
|
let(:backup) { Backup.new(backup_filename) }
|
|
|
|
it "enqueues email job" do
|
|
Backup.expects(:[]).with(backup_filename).returns(backup)
|
|
|
|
Jobs.expects(:enqueue).with(:download_backup_email,
|
|
user_id: admin.id,
|
|
backup_file_path: 'http://www.example.com/admin/backups/test.tar.gz'
|
|
)
|
|
|
|
put "/admin/backups/#{backup_filename}.json"
|
|
|
|
expect(response).to be_successful
|
|
end
|
|
|
|
it "returns 404 when the backup does not exist" do
|
|
put "/admin/backups/#{backup_filename}.json"
|
|
|
|
expect(response).to be_not_found
|
|
end
|
|
|
|
end
|
|
end
|