Add name length validation (#453)
This commit is contained in:
parent
2b0741fe31
commit
74266db0d9
3 changed files with 3 additions and 0 deletions
|
|
@ -39,6 +39,7 @@ class User < ApplicationRecord
|
|||
length: { maximum: 50 },
|
||||
email: true,
|
||||
allow_blank: true
|
||||
validates :name, length: { maximum: 100 }
|
||||
validates :username,
|
||||
presence: true,
|
||||
uniqueness: { case_sensitive: false },
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@
|
|||
'Aman Mahendra',
|
||||
'Kaushik Roy',
|
||||
'Shiv Bihari Pandey',
|
||||
'Sahil Mehra',
|
||||
] %>
|
||||
<% hunters.shuffle.each do |hunter| %>
|
||||
<li><%= hunter %></li>
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ RSpec.describe User, type: :model do
|
|||
it { is_expected.to validate_uniqueness_of(:twitter_username).allow_blank }
|
||||
it { is_expected.to validate_presence_of(:username) }
|
||||
it { is_expected.to validate_length_of(:username).is_at_most(30).is_at_least(2) }
|
||||
it { is_expected.to validate_length_of(:name).is_at_most(100) }
|
||||
|
||||
# the followings are failing
|
||||
# it { is_expected.to have_many(:keys) }
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue