logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

filter_test.exs (954B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 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.Upload.Filter
  7. setup do: clear_config([Pleroma.Upload.Filter.AnonymizeFilename, :text])
  8. test "applies filters" do
  9. clear_config([Pleroma.Upload.Filter.AnonymizeFilename, :text], "custom-file.png")
  10. File.cp!(
  11. "test/fixtures/image.jpg",
  12. "test/fixtures/image_tmp.jpg"
  13. )
  14. upload = %Pleroma.Upload{
  15. name: "an… image.jpg",
  16. content_type: "image/jpeg",
  17. path: Path.absname("test/fixtures/image_tmp.jpg"),
  18. tempfile: Path.absname("test/fixtures/image_tmp.jpg")
  19. }
  20. assert Filter.filter([], upload) == {:ok, upload}
  21. assert {:ok, upload} = Filter.filter([Pleroma.Upload.Filter.AnonymizeFilename], upload)
  22. assert upload.name == "custom-file.png"
  23. end
  24. end