correct specs
This commit is contained in:
parent
9c3ba98ef1
commit
d7b1919ead
|
@ -82,7 +82,7 @@ class UploadCreator
|
|||
# otherwise validation will fail and we can not save
|
||||
# TODO decide if we only run the validation on the extension
|
||||
if File.extname(@filename) != ".#{image_type}"
|
||||
fixed_original_filename = "#{@filename}.fixed.#{image_type}"
|
||||
fixed_original_filename = "#{@filename}_fixed.#{image_type}"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
abcd
|
|
@ -41,7 +41,7 @@ RSpec.describe UploadCreator do
|
|||
|
||||
expect(upload.extension).to eq('png')
|
||||
expect(File.extname(upload.url)).to eq('.png')
|
||||
expect(upload.original_filename).to eq('png_as.bin.fixed.png')
|
||||
expect(upload.original_filename).to eq('png_as.bin_fixed.png')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -65,7 +65,7 @@ RSpec.describe UploadCreator do
|
|||
|
||||
expect(upload.extension).to eq('jpeg')
|
||||
expect(File.extname(upload.url)).to eq('.jpeg')
|
||||
expect(upload.original_filename).to eq('logo.png.fixed.jpeg')
|
||||
expect(upload.original_filename).to eq('logo.png_fixed.jpeg')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -53,8 +53,7 @@ describe Upload do
|
|||
|
||||
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)
|
||||
created_upload = UploadCreator.new(attachment, nil).create_for(user_id)
|
||||
expect(created_upload.valid?).to eq(false)
|
||||
end
|
||||
|
||||
|
|
|
@ -206,13 +206,22 @@ describe UploadsController do
|
|||
expect(response.headers["Content-Disposition"]).to eq("attachment; filename=\"logo.png\"")
|
||||
end
|
||||
|
||||
it "handles file without extension" do
|
||||
it "handles image without extension" do
|
||||
SiteSetting.authorized_extensions = "*"
|
||||
upload = upload_file("image_no_extension")
|
||||
|
||||
get "/uploads/#{site}/#{upload.sha1}.json"
|
||||
expect(response.status).to eq(200)
|
||||
expect(response.headers["Content-Disposition"]).to eq("attachment; filename=\"image_no_extension\"")
|
||||
expect(response.headers["Content-Disposition"]).to eq("attachment; filename=\"image_no_extension_fixed.png\"")
|
||||
end
|
||||
|
||||
it "handles file without extension" do
|
||||
SiteSetting.authorized_extensions = "*"
|
||||
upload = upload_file("not_an_image")
|
||||
|
||||
get "/uploads/#{site}/#{upload.sha1}.json"
|
||||
expect(response.status).to eq(200)
|
||||
expect(response.headers["Content-Disposition"]).to eq("attachment; filename=\"not_an_image\"")
|
||||
end
|
||||
|
||||
context "prevent anons from downloading files" do
|
||||
|
|
Loading…
Reference in New Issue