Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
964B

  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2019 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. 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