remove duplicate accounts fixtures

This commit is contained in:
shibao 2021-09-12 17:57:30 -04:00 committed by oliviasculley
parent 3d1e1c816f
commit 25594fa60d

View File

@ -25,28 +25,10 @@ defmodule Cannery.AccountsFixtures do
token token
end end
def unique_user_email, do: "user#{System.unique_integer()}@example.com"
def valid_user_password, do: "hello world!"
def valid_user_attributes(attrs \\ %{}) do def valid_user_attributes(attrs \\ %{}) do
Enum.into(attrs, %{ Enum.into(attrs, %{
email: unique_user_email(), email: unique_user_email(),
password: valid_user_password() password: valid_user_password()
}) })
end end
def user_fixture(attrs \\ %{}) do
{:ok, user} =
attrs
|> valid_user_attributes()
|> Cannery.Accounts.register_user()
user
end
def extract_user_token(fun) do
{:ok, captured} = fun.(&"[TOKEN]#{&1}[TOKEN]")
[_, token, _] = String.split(captured.body, "[TOKEN]")
token
end
end end