Fix all the errors to get our tests green on Rails 5.1.

This commit is contained in:
Guo Xiang Tan
2017-08-31 12:06:56 +08:00
parent 898ee93547
commit 77d4c4d8dc
989 changed files with 5114 additions and 3117 deletions

View File

@ -3,7 +3,7 @@ require "email_backup_token"
class Admin::BackupsController < Admin::AdminController
skip_before_filter :check_xhr, only: [:index, :show, :logs, :check_backup_chunk, :upload_backup_chunk]
skip_before_action :check_xhr, only: [:index, :show, :logs, :check_backup_chunk, :upload_backup_chunk]
def index
respond_to do |format|
@ -50,9 +50,9 @@ class Admin::BackupsController < Admin::AdminController
token = EmailBackupToken.set(current_user.id)
download_url = "#{url_for(controller: 'backups', action: 'show')}?token=#{token}"
Jobs.enqueue(:download_backup_email, to_address: current_user.email, backup_file_path: download_url)
render nothing: true
render body: nil
else
render nothing: true, status: 404
render body: nil, status: 404
end
end
@ -70,7 +70,7 @@ class Admin::BackupsController < Admin::AdminController
if @error
render layout: 'no_ember', status: 422
else
render nothing: true, status: 404
render body: nil, status: 404
end
end
end
@ -79,9 +79,9 @@ class Admin::BackupsController < Admin::AdminController
if backup = Backup[params.fetch(:id)]
StaffActionLogger.new(current_user).log_backup_destroy(backup)
backup.remove
render nothing: true
render body: nil
else
render nothing: true, status: 404
render body: nil, status: 404
end
end
@ -125,7 +125,7 @@ class Admin::BackupsController < Admin::AdminController
StaffActionLogger.new(current_user).log_change_readonly_mode(enable)
render nothing: true
render body: nil
end
def check_backup_chunk
@ -139,16 +139,16 @@ class Admin::BackupsController < Admin::AdminController
# check chunk upload status
status = HandleChunkUpload.check_chunk(chunk, current_chunk_size: current_chunk_size)
render nothing: true, status: status
render body: nil, status: status
end
def upload_backup_chunk
filename = params.fetch(:resumableFilename)
total_size = params.fetch(:resumableTotalSize).to_i
return render status: 415, text: I18n.t("backup.backup_file_should_be_tar_gz") unless /\.(tar\.gz|t?gz)$/i =~ filename
return render status: 415, text: I18n.t("backup.not_enough_space_on_disk") unless has_enough_space_on_disk?(total_size)
return render status: 415, text: I18n.t("backup.invalid_filename") unless !!(/^[a-zA-Z0-9\._\-]+$/ =~ filename)
return render status: 415, plain: I18n.t("backup.backup_file_should_be_tar_gz") unless /\.(tar\.gz|t?gz)$/i =~ filename
return render status: 415, plain: I18n.t("backup.not_enough_space_on_disk") unless has_enough_space_on_disk?(total_size)
return render status: 415, plain: I18n.t("backup.invalid_filename") unless !!(/^[a-zA-Z0-9\._\-]+$/ =~ filename)
file = params.fetch(:file)
identifier = params.fetch(:resumableIdentifier)
@ -168,7 +168,7 @@ class Admin::BackupsController < Admin::AdminController
Jobs.enqueue_in(5.seconds, :backup_chunks_merger, filename: filename, identifier: identifier, chunks: chunk_number)
end
render nothing: true
render body: nil
end
private