mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FIX: send content length with backups
This commit is contained in:
parent
7a4082cbad
commit
9428ad779f
2 changed files with 8 additions and 4 deletions
|
@ -46,6 +46,7 @@ class Admin::BackupsController < Admin::AdminController
|
|||
def show
|
||||
filename = params.fetch(:id)
|
||||
if backup = Backup[filename]
|
||||
headers['Content-Length'] = File.size(backup.path)
|
||||
send_file backup.path
|
||||
else
|
||||
render nothing: true, status: 404
|
||||
|
|
|
@ -101,13 +101,16 @@ describe Admin::BackupsController do
|
|||
describe ".show" do
|
||||
|
||||
it "uses send_file to transmit the backup" do
|
||||
controller.stubs(:render) # we need this since we're stubing send_file
|
||||
File.open(Backup.base_directory << "/" << backup_filename, "w") do |f|
|
||||
f.write("hello")
|
||||
end
|
||||
|
||||
backup = Backup.new("backup42")
|
||||
Backup.expects(:[]).with(backup_filename).returns(backup)
|
||||
subject.expects(:send_file).with(backup.path)
|
||||
Backup.create_from_filename(backup_filename)
|
||||
|
||||
get :show, id: backup_filename
|
||||
|
||||
response.headers['Content-Length'].should == 5
|
||||
response.headers['Content-Disposition'].should =~ /attachment; filename/
|
||||
end
|
||||
|
||||
it "returns 404 when the backup does not exist" do
|
||||
|
|
Loading…
Reference in a new issue