version chapril de mobilizon https://mobilizon.chapril.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

28 lines
850 B

defmodule Mobilizon.Service.Users.ToolsTest do
use Mobilizon.DataCase
import Mobilizon.Factory
setup do
user = insert(:user)
moderator = insert(:user, role: :moderator)
administrator = insert(:user, role: :administrator)
{:ok, user: user, moderator: moderator, administrator: administrator}
end
describe "test guards" do
import Mobilizon.Users.Guards
test "is_moderator/1 guard", %{user: user, moderator: moderator, administrator: administrator} do
refute is_moderator(user.role)
assert is_moderator(moderator.role)
assert is_moderator(administrator.role)
end
test "is_admin/1 guard", %{user: user, moderator: moderator, administrator: administrator} do
refute is_admin(user.role)
refute is_admin(moderator.role)
assert is_admin(administrator.role)
end
end
end