mirror of
https://github.com/plausible/analytics.git
synced 2024-12-25 18:48:06 +03:00
a4b9c3b8ba
* Disable super-admin checks on small build * Mute a test writing to stdout * Move sampling outside of small build * Convert waiting_first_pageview to heex and stop relying on env vars * Set site limit unlimited on small build * Stop relying on app env to get trial expiry * Remove custom domains - including migration * Remove is_selfhosted from layout view * Quota fixup * Stop relying on app env for self hosted registration * Stop relying on app env for pass reset success * Apply on_trial? check only on full build * Update templates relying on app env * Adjusts auth controller tests for small build * Trial fixup * Fixup * Stop relying on app env * Rest of the fsckn owl * Update typespecs * Fix dialyzer warning * Remove unused module * Credo + format * GeoIP is not, for full build * Use `small_build?()` where applicable * Implement bypassing FirstLaunchPlug without insertions * Get Marko's patchde58a18a85
* Test is-dbip=false presence * Fix typespec * Remove future hardcodes * Handle `nil` from `Plausible.Geo.database_type()` * Remove XXX marker * Use one typespec for two clauses * Introduce `MIX_ENV=small_dev` * Revert "Use one typespec for two clauses" This reverts commit8d8cd21764
.
63 lines
1.7 KiB
Elixir
63 lines
1.7 KiB
Elixir
defmodule PlausibleWeb.FirstLaunchPlugTest do
|
|
use PlausibleWeb.ConnCase
|
|
@moduletag :small_build_only
|
|
import Plug.Test
|
|
|
|
alias PlausibleWeb.FirstLaunchPlug
|
|
alias Plausible.Release
|
|
|
|
describe "init/1" do
|
|
test "requires :redirect_to option" do
|
|
assert_raise KeyError, ~r"key :redirect_to not found", fn ->
|
|
FirstLaunchPlug.init(_no_opts = [])
|
|
end
|
|
|
|
path = FirstLaunchPlug.init(redirect_to: "/register")
|
|
assert path == "/register"
|
|
end
|
|
end
|
|
|
|
@opts FirstLaunchPlug.init(redirect_to: "/register")
|
|
|
|
describe "call/2" do
|
|
test "no-op for paths == :redirect_to" do
|
|
conn = conn("GET", "/register")
|
|
conn = FirstLaunchPlug.call(conn, @opts)
|
|
refute conn.halted
|
|
|
|
# even when it's the first launch
|
|
assert Release.should_be_first_launch?()
|
|
|
|
conn = conn("GET", "/register")
|
|
conn = FirstLaunchPlug.call(conn, @opts)
|
|
refute conn.halted
|
|
end
|
|
|
|
test "no-op when not first launch" do
|
|
insert(:user)
|
|
refute Release.should_be_first_launch?()
|
|
conn = conn("GET", "/sites")
|
|
conn = FirstLaunchPlug.call(conn, @opts)
|
|
refute conn.halted
|
|
end
|
|
|
|
test "redirects to :redirect_to when first launch" do
|
|
assert Release.should_be_first_launch?()
|
|
|
|
conn = conn("GET", "/sites")
|
|
conn = FirstLaunchPlug.call(conn, @opts)
|
|
assert conn.halted
|
|
assert redirected_to(conn) == "/register"
|
|
end
|
|
end
|
|
|
|
describe "first launch plug in :browser pipeline" do
|
|
test "redirects to /register on first launch", %{conn: conn} do
|
|
assert Release.should_be_first_launch?()
|
|
|
|
conn = get(conn, "/")
|
|
assert redirected_to(conn) == "/register"
|
|
end
|
|
end
|
|
end
|