tests: user: add tests for superuser?/1

This commit is contained in:
William Pitcock 2019-01-09 06:50:31 +00:00
parent f15183178c
commit f2a4f89abe
1 changed files with 28 additions and 0 deletions

View File

@ -781,4 +781,32 @@ test "auth_active?/1 works correctly" do
Pleroma.Config.put([:instance, :account_activation_required], false) Pleroma.Config.put([:instance, :account_activation_required], false)
end end
describe "superuser?/1" do
test "returns false for unprivileged users" do
user = insert(:user, local: true)
refute User.superuser?(user)
end
test "returns false for remote users" do
user = insert(:user, local: false)
remote_admin_user = insert(:user, local: false, info: %{is_admin: true})
refute User.superuser?(user)
refute User.superuser?(remote_admin_user)
end
test "returns true for local moderators" do
user = insert(:user, local: true, info: %{is_moderator: true})
assert User.superuser?(user)
end
test "returns true for local admins" do
user = insert(:user, local: true, info: %{is_admin: true})
assert User.superuser?(user)
end
end
end end