summaryrefslogtreecommitdiff
path: root/test/upload_test.exs
diff options
context:
space:
mode:
authorkaniini <nenolod@gmail.com>2018-08-16 15:23:04 +0000
committerkaniini <nenolod@gmail.com>2018-08-16 15:23:04 +0000
commitf2fa09c50fde8db4e619872ef6121e90a69324a6 (patch)
tree4d34037c5fc6d1a3c05a0b061f5279caef1bd671 /test/upload_test.exs
parent718882b326f00c8315bca5acc439b92aa37bf021 (diff)
parent5fbb14f5ecbbd9feeed2a303c2619fbbba07d70e (diff)
downloadpleroma-f2fa09c50fde8db4e619872ef6121e90a69324a6.tar.gz
pleroma-f2fa09c50fde8db4e619872ef6121e90a69324a6.zip
Merge branch 'develop' into 'patch-2'
# Conflicts: # mix.exs
Diffstat (limited to 'test/upload_test.exs')
-rw-r--r--test/upload_test.exs26
1 files changed, 26 insertions, 0 deletions
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