1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Upload.FilterTest do
9 alias Pleroma.Upload.Filter
11 clear_config([Pleroma.Upload.Filter.AnonymizeFilename, :text])
13 test "applies filters" do
14 Config.put([Pleroma.Upload.Filter.AnonymizeFilename, :text], "custom-file.png")
17 "test/fixtures/image.jpg",
18 "test/fixtures/image_tmp.jpg"
21 upload = %Pleroma.Upload{
22 name: "an… image.jpg",
23 content_type: "image/jpg",
24 path: Path.absname("test/fixtures/image_tmp.jpg"),
25 tempfile: Path.absname("test/fixtures/image_tmp.jpg")
28 assert Filter.filter([], upload) == {:ok, upload}
30 assert {:ok, upload} = Filter.filter([Pleroma.Upload.Filter.AnonymizeFilename], upload)
31 assert upload.name == "custom-file.png"