Add minimum name length for users (#594)
This commit is contained in:
parent
6f9248c97e
commit
b2b1068715
2 changed files with 8 additions and 1 deletions
|
|
@ -40,7 +40,7 @@ class User < ApplicationRecord
|
|||
length: { maximum: 50 },
|
||||
email: true,
|
||||
allow_blank: true
|
||||
validates :name, length: { maximum: 100 }
|
||||
validates :name, length: { minimum: 1, maximum: 100 }
|
||||
validates :username,
|
||||
presence: true,
|
||||
uniqueness: { case_sensitive: false },
|
||||
|
|
|
|||
|
|
@ -145,6 +145,13 @@ RSpec.describe User, type: :model do
|
|||
expect(user.old_old_username).to eq(old_username)
|
||||
end
|
||||
|
||||
it "does not allow too short or too long name" do
|
||||
user.name = ""
|
||||
expect(user).not_to be_valid
|
||||
user.name = Faker::Lorem.paragraph_by_chars(200)
|
||||
expect(user).not_to be_valid
|
||||
end
|
||||
|
||||
it "does not accept invalid employer url" do
|
||||
user.employer_url = "ben.com"
|
||||
expect(user).not_to be_valid
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue