logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma

filter_test.exs (974B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Upload.FilterTest do
  5. use Pleroma.DataCase
  6. alias Pleroma.Config
  7. alias Pleroma.Upload.Filter
  8. setup do: clear_config([Pleroma.Upload.Filter.AnonymizeFilename, :text])
  9. test "applies filters" do
  10. Config.put([Pleroma.Upload.Filter.AnonymizeFilename, :text], "custom-file.png")
  11. File.cp!(
  12. "test/fixtures/image.jpg",
  13. "test/fixtures/image_tmp.jpg"
  14. )
  15. upload = %Pleroma.Upload{
  16. name: "an… image.jpg",
  17. content_type: "image/jpg",
  18. path: Path.absname("test/fixtures/image_tmp.jpg"),
  19. tempfile: Path.absname("test/fixtures/image_tmp.jpg")
  20. }
  21. assert Filter.filter([], upload) == {:ok, upload}
  22. assert {:ok, upload} = Filter.filter([Pleroma.Upload.Filter.AnonymizeFilename], upload)
  23. assert upload.name == "custom-file.png"
  24. end
  25. end