Add functions to add admins

This commit is contained in:
João Gilberto Balsini Moura 2020-09-12 21:37:05 -03:00
parent 33029dae04
commit bda3f949b8
3 changed files with 46 additions and 1 deletions
test/real_estate

View file

@ -83,13 +83,26 @@ defmodule RealEstate.AccountsTest do
assert "has already been taken" in errors_on(changeset).email
end
test "registers users with a hashed password" do
test "registers users with a hashed password and sets role to :user" do
email = unique_user_email()
{:ok, user} = Accounts.register_user(%{email: email, password: valid_user_password()})
assert user.email == email
assert is_binary(user.hashed_password)
assert is_nil(user.confirmed_at)
assert is_nil(user.password)
assert user.role == :user
end
end
describe "register_admin/1" do
test "registers users with a hashed password and sets role to :admin" do
email = unique_user_email()
{:ok, user} = Accounts.register_admin(%{email: email, password: valid_user_password()})
assert user.email == email
assert is_binary(user.hashed_password)
assert is_nil(user.confirmed_at)
assert is_nil(user.password)
assert user.role == :admin
end
end