summaryrefslogtreecommitdiff
path: root/test/upload/filter_test.exs
diff options
context:
space:
mode:
authorRoman Chvanikov <chvanikoff@pm.me>2019-07-20 01:03:25 +0300
committerRoman Chvanikov <chvanikoff@pm.me>2019-07-20 01:03:25 +0300
commit36049f08efadb5f6f727753ecc1f7be6a5b4e3d8 (patch)
tree2f1e1b5a20ad654cda4021115e621887d2735959 /test/upload/filter_test.exs
parente7c175c943e9e3f53df76d812c09cfeffdb1c56b (diff)
parent33729bbb2834bfa1f223b11d47dc8e3230d47657 (diff)
downloadpleroma-36049f08efadb5f6f727753ecc1f7be6a5b4e3d8.tar.gz
pleroma-36049f08efadb5f6f727753ecc1f7be6a5b4e3d8.zip
Merge develop
Diffstat (limited to 'test/upload/filter_test.exs')
-rw-r--r--test/upload/filter_test.exs39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/upload/filter_test.exs b/test/upload/filter_test.exs
new file mode 100644
index 000000000..640cd7107
--- /dev/null
+++ b/test/upload/filter_test.exs
@@ -0,0 +1,39 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2019 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
+ custom_filename = Config.get([Pleroma.Upload.Filter.AnonymizeFilename, :text])
+
+ on_exit(fn ->
+ Config.put([Pleroma.Upload.Filter.AnonymizeFilename, :text], custom_filename)
+ end)
+ end
+
+ 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/jpg",
+ 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