diff options
author | Roman Chvanikov <chvanikoff@pm.me> | 2019-07-20 01:03:25 +0300 |
---|---|---|
committer | Roman Chvanikov <chvanikoff@pm.me> | 2019-07-20 01:03:25 +0300 |
commit | 36049f08efadb5f6f727753ecc1f7be6a5b4e3d8 (patch) | |
tree | 2f1e1b5a20ad654cda4021115e621887d2735959 /test/upload/filter_test.exs | |
parent | e7c175c943e9e3f53df76d812c09cfeffdb1c56b (diff) | |
parent | 33729bbb2834bfa1f223b11d47dc8e3230d47657 (diff) | |
download | pleroma-36049f08efadb5f6f727753ecc1f7be6a5b4e3d8.tar.gz pleroma-36049f08efadb5f6f727753ecc1f7be6a5b4e3d8.zip |
Merge develop
Diffstat (limited to 'test/upload/filter_test.exs')
-rw-r--r-- | test/upload/filter_test.exs | 39 |
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 |