From 0a95b5594b654dbec73a9e50e340f4975aa3e8e5 Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Thu, 14 Jun 2018 12:12:38 -0400 Subject: Add missing file extension if file does not have one --- test/upload_test.exs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test') diff --git a/test/upload_test.exs b/test/upload_test.exs index 645f10293..09aa5e068 100644 --- a/test/upload_test.exs +++ b/test/upload_test.exs @@ -43,5 +43,18 @@ defmodule Pleroma.UploadTest do data = Upload.store(file, true) assert hd(data["url"])["mediaType"] == "image/jpeg" end + + test "adds missing extension" do + File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg") + + file = %Plug.Upload{ + content_type: "image/jpg", + path: Path.absname("test/fixtures/image_tmp.jpg"), + filename: "an [image" + } + + data = Upload.store(file, false) + assert data["name"] == "an [image.jpg" + end end end -- cgit v1.2.3