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:
@@ -102,7 +102,7 @@ class PostVoteTest < ActiveSupport::TestCase
|
||||
|
||||
context "deleting a vote by another user" do
|
||||
should "leave a mod action" do
|
||||
admin = create(:admin_user, name: "admin")
|
||||
admin = create(:admin_user)
|
||||
vote = create(:post_vote, post: @post, score: 1)
|
||||
|
||||
vote.soft_delete!(updater: admin)
|
||||
@@ -114,7 +114,7 @@ class PostVoteTest < ActiveSupport::TestCase
|
||||
|
||||
context "undeleting a vote by another user" do
|
||||
setup do
|
||||
@admin = create(:admin_user, name: "admin")
|
||||
@admin = create(:admin_user)
|
||||
@vote = create(:post_vote, post: @post, score: 1)
|
||||
|
||||
@vote.soft_delete!(updater: @admin)
|
||||
|
||||
@@ -205,6 +205,13 @@ class UserTest < ActiveSupport::TestCase
|
||||
user.save
|
||||
assert_equal(["Name is not allowed"], user.errors.full_messages)
|
||||
end
|
||||
|
||||
should_not allow_value("any").for(:name)
|
||||
should_not allow_value("none").for(:name)
|
||||
should_not allow_value("new").for(:name)
|
||||
should_not allow_value("admin").for(:name)
|
||||
should_not allow_value("mod").for(:name)
|
||||
should_not allow_value("moderator").for(:name)
|
||||
end
|
||||
|
||||
context "searching for users by name" do
|
||||
|
||||
Reference in New Issue
Block a user