users: don't allow users to choose reserved names.

Don't allow users to choose names that conflict with search syntax, like `any` or `none`, or names
that impersonate user levels, like `Admin`, `Moderator`, `Anonymous`, etc.
This commit is contained in:
evazion
2022-11-06 15:46:38 -06:00
parent 8bd60e41a1
commit c133866cb7
6 changed files with 25 additions and 9 deletions

View File

@@ -32,7 +32,7 @@ class BansControllerTest < ActionDispatch::IntegrationTest
context "index action" do
setup do
@mod = create(:mod_user, name: "mod")
@mod = create(:mod_user, name: "mod123")
@ban1 = create(:ban, created_at: 1.week.ago, duration: 1.day)
@ban2 = create(:ban, user: build(:builder_user), reason: "blah", banner: @mod, duration: 100.years)
end
@@ -47,7 +47,7 @@ class BansControllerTest < ActionDispatch::IntegrationTest
should respond_to_search(expired: "false").with { @ban2 }
should respond_to_search(duration: "<1w").with { @ban1 }
should respond_to_search(banner_name: "mod").with { @ban2 }
should respond_to_search(banner_name: "mod123").with { @ban2 }
should respond_to_search(banner: { level: User::Levels::MODERATOR }).with { @ban2 }
end