Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

48 líneas
1.5KB

  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Web.RuntimeStaticPlugTest do
  5. use Pleroma.Web.ConnCase
  6. @dir "test/tmp/instance_static"
  7. setup do
  8. static_dir = Pleroma.Config.get([:instance, :static_dir])
  9. Pleroma.Config.put([:instance, :static_dir], @dir)
  10. File.mkdir_p!(@dir)
  11. on_exit(fn ->
  12. Pleroma.Config.put([:instance, :static_dir], static_dir)
  13. File.rm_rf(@dir)
  14. end)
  15. end
  16. test "overrides index" do
  17. bundled_index = get(build_conn(), "/")
  18. assert html_response(bundled_index, 200) == File.read!("priv/static/index.html")
  19. File.write!(@dir <> "/index.html", "hello world")
  20. index = get(build_conn(), "/")
  21. assert html_response(index, 200) == "hello world"
  22. end
  23. test "overrides any file in static/static" do
  24. bundled_index = get(build_conn(), "/static/terms-of-service.html")
  25. assert html_response(bundled_index, 200) ==
  26. File.read!("priv/static/static/terms-of-service.html")
  27. File.mkdir!(@dir <> "/static")
  28. File.write!(@dir <> "/static/terms-of-service.html", "plz be kind")
  29. index = get(build_conn(), "/static/terms-of-service.html")
  30. assert html_response(index, 200) == "plz be kind"
  31. File.write!(@dir <> "/static/kaniini.html", "<h1>rabbit hugs as a service</h1>")
  32. index = get(build_conn(), "/static/kaniini.html")
  33. assert html_response(index, 200) == "<h1>rabbit hugs as a service</h1>"
  34. end
  35. end