-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create and use Auth.PeopleRoles.list_people_roles/0 function to list …
- Loading branch information
Showing
5 changed files
with
23 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,14 +4,20 @@ defmodule AuthWeb.PeopleRolesTest do | |
test "grant_role/3 happy path", %{conn: conn} do | ||
# login as superadmin | ||
conn = AuthTest.admin_login(conn) | ||
# create a new person | ||
# create a new person | ||
alex = %{email: "[email protected]", auth_provider: "email"} | ||
grantee = Auth.Person.create_person(alex) | ||
role_id = 4 | ||
Auth.PeopleRoles.grant_role(conn, grantee.id, role_id) | ||
person_with_role = Auth.Person.get_person_by_id(grantee.id) | ||
person_with_role = Auth.Person.get_person_by_id(grantee.id) # |> IO.inspect() | ||
role = List.first(person_with_role.roles) | ||
assert role_id == role.id | ||
|
||
# check the latest people_roles record: | ||
pr = List.last(Auth.PeopleRoles.list_people_roles()) | ||
assert pr.granter_id == 1 | ||
assert pr.person_id == grantee.id | ||
|
||
end | ||
|
||
test "attempt to grant_role/3 without admin should 401", %{conn: conn} do | ||
|
@@ -20,7 +26,6 @@ defmodule AuthWeb.PeopleRolesTest do | |
conn = assign(conn, :person, grantee) | ||
role_id = 4 | ||
conn = Auth.PeopleRoles.grant_role(conn, grantee.id, role_id) | ||
|
||
assert conn.status == 401 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters