FIX: empty uploads and blank filenames caused errors during validation
This commit is contained in:
parent
76e8a28420
commit
f525d83b53
|
@ -21,9 +21,9 @@ class UploadCreator
|
|||
# - for_private_message (boolean)
|
||||
# - pasted (boolean)
|
||||
def initialize(file, filename, opts = {})
|
||||
@upload = Upload.new
|
||||
@file = file
|
||||
@filename = filename
|
||||
@filename = filename || ''
|
||||
@upload = Upload.new(original_filename: filename, filesize: 0)
|
||||
@opts = opts
|
||||
end
|
||||
|
||||
|
|
|
@ -51,6 +51,13 @@ describe Upload do
|
|||
expect(created_upload.extension).to eq("png")
|
||||
end
|
||||
|
||||
it "should create an invalid upload when the filename is blank" do
|
||||
SiteSetting.authorized_extensions = "*"
|
||||
|
||||
created_upload = UploadCreator.new(image, nil).create_for(user_id)
|
||||
expect(created_upload.valid?).to eq(false)
|
||||
end
|
||||
|
||||
context ".get_from_url" do
|
||||
let(:url) { "/uploads/default/original/3X/1/0/10f73034616a796dfd70177dc54b6def44c4ba6f.png" }
|
||||
let(:upload) { Fabricate(:upload, url: url) }
|
||||
|
|
Loading…
Reference in New Issue