basic_signup_allowlist/test/basic_signup_allowlist_test.exs
2025-09-16 09:09:51 +00:00

30 lines
803 B
Elixir

defmodule BasicSignupAllowlistTest do
use ExUnit.Case, async: false
doctest BasicSignupAllowlist
defp allow_signups_for(allowlist) do
System.put_env("SIGNUP_ALLOWLIST_EMAILS", allowlist)
end
describe "setup in describe block" do
setup do
on_exit(fn ->
# resetting values did not work, so 'just' set it to the effect without this module configured.
System.put_env("SIGNUP_ALLOWLIST_EMAILS", "*")
end)
:ok
end
test "When not set, not allowlisted" do
System.delete_env("SIGNUP_ALLOWLIST_EMAILS")
refute BasicSignupAllowlist.mail_allowlisted("joe@example.com")
end
test "When set to star, allowlisted" do
allow_signups_for("*")
assert BasicSignupAllowlist.mail_allowlisted("joe@example.com")
end
end
end