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.

46 lines
1.4KB

  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. File.mkdir_p!(@dir)
  9. on_exit(fn -> File.rm_rf(@dir) end)
  10. end
  11. clear_config([:instance, :static_dir]) do
  12. Pleroma.Config.put([:instance, :static_dir], @dir)
  13. end
  14. test "overrides index" do
  15. bundled_index = get(build_conn(), "/")
  16. assert html_response(bundled_index, 200) == File.read!("priv/static/index.html")
  17. File.write!(@dir <> "/index.html", "hello world")
  18. index = get(build_conn(), "/")
  19. assert html_response(index, 200) == "hello world"
  20. end
  21. test "overrides any file in static/static" do
  22. bundled_index = get(build_conn(), "/static/terms-of-service.html")
  23. assert html_response(bundled_index, 200) ==
  24. File.read!("priv/static/static/terms-of-service.html")
  25. File.mkdir!(@dir <> "/static")
  26. File.write!(@dir <> "/static/terms-of-service.html", "plz be kind")
  27. index = get(build_conn(), "/static/terms-of-service.html")
  28. assert html_response(index, 200) == "plz be kind"
  29. File.write!(@dir <> "/static/kaniini.html", "<h1>rabbit hugs as a service</h1>")
  30. index = get(build_conn(), "/static/kaniini.html")
  31. assert html_response(index, 200) == "<h1>rabbit hugs as a service</h1>"
  32. end
  33. end