summaryrefslogtreecommitdiff
path: root/test/pleroma/upload/filter_test.exs
diff options
context:
space:
mode:
Diffstat (limited to 'test/pleroma/upload/filter_test.exs')
-rw-r--r--test/pleroma/upload/filter_test.exs33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/pleroma/upload/filter_test.exs b/test/pleroma/upload/filter_test.exs
new file mode 100644
index 000000000..09394929c
--- /dev/null
+++ b/test/pleroma/upload/filter_test.exs
@@ -0,0 +1,33 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Upload.FilterTest do
+ use Pleroma.DataCase
+
+ alias Pleroma.Config
+ alias Pleroma.Upload.Filter
+
+ setup do: clear_config([Pleroma.Upload.Filter.AnonymizeFilename, :text])
+
+ test "applies filters" do
+ Config.put([Pleroma.Upload.Filter.AnonymizeFilename, :text], "custom-file.png")
+
+ File.cp!(
+ "test/fixtures/image.jpg",
+ "test/fixtures/image_tmp.jpg"
+ )
+
+ upload = %Pleroma.Upload{
+ name: "an… image.jpg",
+ content_type: "image/jpeg",
+ path: Path.absname("test/fixtures/image_tmp.jpg"),
+ tempfile: Path.absname("test/fixtures/image_tmp.jpg")
+ }
+
+ assert Filter.filter([], upload) == {:ok, upload}
+
+ assert {:ok, upload} = Filter.filter([Pleroma.Upload.Filter.AnonymizeFilename], upload)
+ assert upload.name == "custom-file.png"
+ end
+end