Patch auth test fixtures for username support
This commit is contained in:
parent
c2faafe3a3
commit
7ea4241f23
3 changed files with 7 additions and 5 deletions
|
@ -5,14 +5,14 @@ defmodule RecycledCloud.AccountsTest do
|
|||
import RecycledCloud.AccountsFixtures
|
||||
alias RecycledCloud.Accounts.{User, UserToken}
|
||||
|
||||
describe "get_user_by_email/1" do
|
||||
test "does not return the user if the email does not exist" do
|
||||
refute Accounts.get_user_by_email("unknown@example.com")
|
||||
describe "get_user_by_username/1" do
|
||||
test "does not return the user if the username does not exist" do
|
||||
refute Accounts.get_user_by_email("unknown")
|
||||
end
|
||||
|
||||
test "returns the user if the email exists" do
|
||||
%{id: id} = user = user_fixture()
|
||||
assert %User{id: ^id} = Accounts.get_user_by_email(user.email)
|
||||
assert %User{id: ^id} = Accounts.get_user_by_username(user.username)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3,6 +3,6 @@ defmodule RecycledCloudWeb.PageControllerTest do
|
|||
|
||||
test "GET /", %{conn: conn} do
|
||||
conn = get(conn, "/")
|
||||
assert html_response(conn, 200) =~ "Welcome to Phoenix!"
|
||||
assert html_response(conn, 200) =~ "Welcome on"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,12 +5,14 @@ defmodule RecycledCloud.AccountsFixtures do
|
|||
"""
|
||||
|
||||
def unique_user_email, do: "user#{System.unique_integer()}@example.com"
|
||||
def unique_user_name, do: "user#{System.unique_integer()}"
|
||||
def valid_user_password, do: "hello world!"
|
||||
|
||||
def user_fixture(attrs \\ %{}) do
|
||||
{:ok, user} =
|
||||
attrs
|
||||
|> Enum.into(%{
|
||||
username: unique_user_name(),
|
||||
email: unique_user_email(),
|
||||
password: valid_user_password()
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue