diff --git a/lib/rbac.ex b/lib/rbac.ex index be4c46b..d9c624c 100644 --- a/lib/rbac.ex +++ b/lib/rbac.ex @@ -110,6 +110,9 @@ defmodule RBAC do @doc """ `has_role/2 confirms if the person has the given role + e.g: + has_role(conn, "home_admin") > true + has_role(conn, "potus") > false """ def has_role(conn, role_name) do role = get_role_from_cache(role_name) diff --git a/test/rbac_test.exs b/test/rbac_test.exs index 8a73fe3..e2aa35a 100644 --- a/test/rbac_test.exs +++ b/test/rbac_test.exs @@ -154,4 +154,19 @@ defmodule RBACTest do assert not RBAC.has_role(fake_conn, "non_existent_role") end + + + test "RBAC.has_role/1 works with integers too!" do + init() + + fake_conn = %{ + assigns: %{ + person: %{ + roles: "1,2,3" + } + } + } + + assert RBAC.has_role(fake_conn, 3) + end end