diff options
author | kaniini <nenolod@gmail.com> | 2018-08-16 15:17:17 +0000 |
---|---|---|
committer | kaniini <nenolod@gmail.com> | 2018-08-16 15:17:17 +0000 |
commit | 8dc715b30bf310d040f72c0c01a5c668c3696b2a (patch) | |
tree | aefed2ddb05ec430cf91a82d550ac3c1e5ce3462 /test | |
parent | 9908cf8fda7d47f23456033cd8c77126d14c81ab (diff) | |
parent | 082920044abeadb9daf593d7e58d210634f8b4a5 (diff) | |
download | pleroma-8dc715b30bf310d040f72c0c01a5c668c3696b2a.tar.gz |
Merge branch 'fix/normalize-file-extension' into 'develop'
Normalize file extension for uploaded files
Closes #218
See merge request pleroma/pleroma!233
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 |