users: add new owner level.

Add a new Owner user level for the site owner. Highly sensitive
operations like manually changing the passwords of other users will be
restricted to the site owner.
This commit is contained in:
evazion
2020-12-13 14:55:49 -06:00
parent 35134abe8f
commit b3ad13e6e3
7 changed files with 33 additions and 3 deletions

View File

@@ -56,6 +56,11 @@ FactoryBot.define do
can_approve_posts {true}
end
factory(:owner_user) do
level { User::Levels::OWNER }
can_approve_posts {true}
end
factory(:uploader) do
created_at { 2.weeks.ago }
end

View File

@@ -1,6 +1,6 @@
class UserMailerPreview < ActionMailer::Preview
def dmail_notice
dmail = User.admins.first.dmails.first
dmail = User.system.dmails.first
UserMailer.dmail_notice(dmail)
end

View File

@@ -45,7 +45,14 @@ class UserTest < ActiveSupport::TestCase
end
should "normalize its level" do
user = FactoryBot.create(:user, :level => User::Levels::OWNER)
assert(user.is_owner?)
assert(user.is_admin?)
assert(user.is_moderator?)
assert(user.is_gold?)
user = FactoryBot.create(:user, :level => User::Levels::ADMIN)
assert(!user.is_owner?)
assert(user.is_moderator?)
assert(user.is_gold?)