From f2a4f89abef810f1106afa3a9ef82fa748bc783e Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Wed, 9 Jan 2019 06:50:31 +0000 Subject: [PATCH] tests: user: add tests for superuser?/1 --- test/user_test.exs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/user_test.exs b/test/user_test.exs index 1c4e84914..582374fb9 100644 --- a/test/user_test.exs +++ b/test/user_test.exs @@ -781,4 +781,32 @@ defmodule Pleroma.UserTest do Pleroma.Config.put([:instance, :account_activation_required], false) 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 -- 2.45.2