mirror of
https://github.com/plausible/analytics.git
synced 2024-12-27 03:21:37 +03:00
0b7870dc4d
* first launch * dynamic children, wait for repo * remove wait_for_repo and app env manipulations * don't mention free trial in self-hosted pages * add changelog * assigns[:is_selfhost] -> @is_selfhost * better changelog wording * rm admin_user, admin_email, admin_pwd from app env * rm DISABLE_AUTH * redirect / to /login when not authenticated * remove TODO * Update lib/plausible_web/controllers/page_controller.ex Co-authored-by: Uku Taht <Uku.taht@gmail.com> * format Co-authored-by: Uku Taht <Uku.taht@gmail.com>
34 lines
906 B
Elixir
34 lines
906 B
Elixir
defmodule PlausibleWeb.AdminAuthControllerTest do
|
|
use PlausibleWeb.ConnCase
|
|
alias Plausible.Release
|
|
|
|
setup_patch_env(:is_selfhost, true)
|
|
|
|
describe "GET /" do
|
|
test "disable registration", %{conn: conn} do
|
|
prevent_first_launch()
|
|
patch_config(disable_registration: true)
|
|
conn = get(conn, "/register")
|
|
assert redirected_to(conn) == "/login"
|
|
end
|
|
|
|
test "disable registration + first launch", %{conn: conn} do
|
|
patch_config(disable_registration: true)
|
|
assert Release.should_be_first_launch?()
|
|
|
|
# "first launch" takes precedence
|
|
conn = get(conn, "/register")
|
|
assert html_response(conn, 200) =~ "Enter your details"
|
|
end
|
|
end
|
|
|
|
def patch_config(config) do
|
|
updated_config = Keyword.merge([disable_registration: false], config)
|
|
patch_env(:selfhost, updated_config)
|
|
end
|
|
|
|
defp prevent_first_launch do
|
|
insert(:user)
|
|
end
|
|
end
|