Delete test/plausible_web/plugs/first_launch_plug_test.exs with huggingface_hub
Browse files
test/plausible_web/plugs/first_launch_plug_test.exs
DELETED
|
@@ -1,62 +0,0 @@
|
|
| 1 |
-
defmodule PlausibleWeb.FirstLaunchPlugTest do
|
| 2 |
-
use PlausibleWeb.ConnCase
|
| 3 |
-
@moduletag :ce_build_only
|
| 4 |
-
import Plug.Test
|
| 5 |
-
|
| 6 |
-
alias PlausibleWeb.FirstLaunchPlug
|
| 7 |
-
alias Plausible.Release
|
| 8 |
-
|
| 9 |
-
describe "init/1" do
|
| 10 |
-
test "requires :redirect_to option" do
|
| 11 |
-
assert_raise KeyError, ~r"key :redirect_to not found", fn ->
|
| 12 |
-
FirstLaunchPlug.init(_no_opts = [])
|
| 13 |
-
end
|
| 14 |
-
|
| 15 |
-
path = FirstLaunchPlug.init(redirect_to: "/register")
|
| 16 |
-
assert path == "/register"
|
| 17 |
-
end
|
| 18 |
-
end
|
| 19 |
-
|
| 20 |
-
@opts FirstLaunchPlug.init(redirect_to: "/register")
|
| 21 |
-
|
| 22 |
-
describe "call/2" do
|
| 23 |
-
test "no-op for paths == :redirect_to" do
|
| 24 |
-
conn = conn("GET", "/register")
|
| 25 |
-
conn = FirstLaunchPlug.call(conn, @opts)
|
| 26 |
-
refute conn.halted
|
| 27 |
-
|
| 28 |
-
# even when it's the first launch
|
| 29 |
-
assert Release.should_be_first_launch?()
|
| 30 |
-
|
| 31 |
-
conn = conn("GET", "/register")
|
| 32 |
-
conn = FirstLaunchPlug.call(conn, @opts)
|
| 33 |
-
refute conn.halted
|
| 34 |
-
end
|
| 35 |
-
|
| 36 |
-
test "no-op when not first launch" do
|
| 37 |
-
insert(:user)
|
| 38 |
-
refute Release.should_be_first_launch?()
|
| 39 |
-
conn = conn("GET", "/sites")
|
| 40 |
-
conn = FirstLaunchPlug.call(conn, @opts)
|
| 41 |
-
refute conn.halted
|
| 42 |
-
end
|
| 43 |
-
|
| 44 |
-
test "redirects to :redirect_to when first launch" do
|
| 45 |
-
assert Release.should_be_first_launch?()
|
| 46 |
-
|
| 47 |
-
conn = conn("GET", "/sites")
|
| 48 |
-
conn = FirstLaunchPlug.call(conn, @opts)
|
| 49 |
-
assert conn.halted
|
| 50 |
-
assert redirected_to(conn) == "/register"
|
| 51 |
-
end
|
| 52 |
-
end
|
| 53 |
-
|
| 54 |
-
describe "first launch plug in :browser pipeline" do
|
| 55 |
-
test "redirects to /register on first launch", %{conn: conn} do
|
| 56 |
-
assert Release.should_be_first_launch?()
|
| 57 |
-
|
| 58 |
-
conn = get(conn, "/")
|
| 59 |
-
assert redirected_to(conn) == "/register"
|
| 60 |
-
end
|
| 61 |
-
end
|
| 62 |
-
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|