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