forked from shibao/cannery
fix tests
This commit is contained in:
parent
f1139d0ec4
commit
fd0b2c455a
@ -42,8 +42,6 @@ config :lokal, Lokal.Repo,
|
|||||||
pool_size: String.to_integer(System.get_env("POOL_SIZE", "10")),
|
pool_size: String.to_integer(System.get_env("POOL_SIZE", "10")),
|
||||||
socket_options: maybe_ipv6
|
socket_options: maybe_ipv6
|
||||||
|
|
||||||
config :lokal, Lokal.Accounts, registration: System.get_env("REGISTRATION", "invite")
|
|
||||||
|
|
||||||
config :lokal, LokalWeb.Endpoint,
|
config :lokal, LokalWeb.Endpoint,
|
||||||
url: [scheme: "https", host: host, port: 443],
|
url: [scheme: "https", host: host, port: 443],
|
||||||
http: [
|
http: [
|
||||||
@ -54,6 +52,10 @@ config :lokal, LokalWeb.Endpoint,
|
|||||||
],
|
],
|
||||||
server: true
|
server: true
|
||||||
|
|
||||||
|
if config_env() in [:dev, :prod] do
|
||||||
|
config :lokal, Lokal.Accounts, registration: System.get_env("REGISTRATION", "invite")
|
||||||
|
end
|
||||||
|
|
||||||
if config_env() == :prod do
|
if config_env() == :prod do
|
||||||
# The secret key base is used to sign/encrypt cookies and other secrets.
|
# The secret key base is used to sign/encrypt cookies and other secrets.
|
||||||
# A default value is used in config/dev.exs and config/test.exs but you
|
# A default value is used in config/dev.exs and config/test.exs but you
|
||||||
|
@ -22,6 +22,9 @@ config :lokal, LokalWeb.Endpoint,
|
|||||||
# In test we don't send emails.
|
# In test we don't send emails.
|
||||||
config :lokal, Lokal.Mailer, adapter: Swoosh.Adapters.Test
|
config :lokal, Lokal.Mailer, adapter: Swoosh.Adapters.Test
|
||||||
|
|
||||||
|
# Don't require invites for signups
|
||||||
|
config :lokal, Lokal.Accounts, registration: "public"
|
||||||
|
|
||||||
# Print only warnings and errors during test
|
# Print only warnings and errors during test
|
||||||
config :logger, level: :warn
|
config :logger, level: :warn
|
||||||
|
|
||||||
|
@ -117,6 +117,8 @@ defmodule Lokal.Accounts do
|
|||||||
:passed
|
:passed
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@spec register_user(attrs :: map()) ::
|
||||||
|
{:ok, User.t()} | {:error, :invalid_token | User.changeset()}
|
||||||
@spec register_user(attrs :: map(), Invite.token() | nil) ::
|
@spec register_user(attrs :: map(), Invite.token() | nil) ::
|
||||||
{:ok, User.t()} | {:error, :invalid_token | User.changeset()}
|
{:ok, User.t()} | {:error, :invalid_token | User.changeset()}
|
||||||
def register_user(attrs, invite_token \\ nil) do
|
def register_user(attrs, invite_token \\ nil) do
|
||||||
|
@ -85,7 +85,9 @@ defmodule Lokal.Accounts.Invites do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec get_invite_by_token(Invite.token()) :: {:ok, Invite.t()} | {:error, :invalid_token}
|
@spec get_invite_by_token(Invite.token() | nil) :: {:ok, Invite.t()} | {:error, :invalid_token}
|
||||||
|
defp get_invite_by_token(token) when token in [nil, ""], do: {:error, :invalid_token}
|
||||||
|
|
||||||
defp get_invite_by_token(token) do
|
defp get_invite_by_token(token) do
|
||||||
Repo.one(
|
Repo.one(
|
||||||
from i in Invite,
|
from i in Invite,
|
||||||
|
Loading…
Reference in New Issue
Block a user