summaryrefslogtreecommitdiff
path: root/test/upload/filter_test.exs
diff options
context:
space:
mode:
authorMaxim Filippov <colixer@gmail.com>2019-07-18 23:38:38 +0300
committerMaxim Filippov <colixer@gmail.com>2019-07-18 23:38:38 +0300
commit9570a5be405c4cf4f07907eab4ced21e07fa20c9 (patch)
tree9575741206d0604e74ab2d8f719c3da0a3002b1d /test/upload/filter_test.exs
parent418ae6638d64c915ce4dae742dd493f43c8025d8 (diff)
parent16cfee708ec8e9c6cbbeb15432127c7757c5c173 (diff)
downloadpleroma-9570a5be405c4cf4f07907eab4ced21e07fa20c9.tar.gz
pleroma-9570a5be405c4cf4f07907eab4ced21e07fa20c9.zip
Merge branch 'develop' into feature/admin-api-user-statuses
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