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