diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/fixtures/test.txt | 1 | ||||
-rw-r--r-- | test/upload_test.exs | 26 |
2 files changed, 27 insertions, 0 deletions
diff --git a/test/fixtures/test.txt b/test/fixtures/test.txt new file mode 100644 index 000000000..e9ea42a12 --- /dev/null +++ b/test/fixtures/test.txt @@ -0,0 +1 @@ +this is a text file diff --git a/test/upload_test.exs b/test/upload_test.exs index 09aa5e068..d273ea5f6 100644 --- a/test/upload_test.exs +++ b/test/upload_test.exs @@ -56,5 +56,31 @@ defmodule Pleroma.UploadTest do data = Upload.store(file, false) assert data["name"] == "an [image.jpg" end + + test "fixes incorrect file 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.blah" + } + + data = Upload.store(file, false) + assert data["name"] == "an [image.jpg" + end + + test "don't modify filename of an unknown type" do + File.cp("test/fixtures/test.txt", "test/fixtures/test_tmp.txt") + + file = %Plug.Upload{ + content_type: "text/plain", + path: Path.absname("test/fixtures/test_tmp.txt"), + filename: "test.txt" + } + + data = Upload.store(file, false) + assert data["name"] == "test.txt" + end end end |