diff options
| author | Maksim <parallel588@gmail.com> | 2019-07-16 21:35:43 +0000 |
|---|---|---|
| committer | kaniini <ariadne@dereferenced.org> | 2019-07-16 21:35:43 +0000 |
| commit | 21e3f9ac69e258d7c46e0f2acdcf011f74cba8e3 (patch) | |
| tree | 3e28284e3596f3ddf7b24dbacf88fa48d16d4236 /test/upload/filter_test.exs | |
| parent | 4ac269a2c37f335d56c91bcda81e006b6d5e6999 (diff) | |
| download | pleroma-21e3f9ac69e258d7c46e0f2acdcf011f74cba8e3.tar.gz pleroma-21e3f9ac69e258d7c46e0f2acdcf011f74cba8e3.zip | |
added tests for Pleroma.Upload.Filter
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 |
