Well, 2 letter usernames are fine too
This commit is contained in:
parent
a6bb7bf5ba
commit
ace357187c
@ -1,6 +1,6 @@
|
||||
class User < ActiveRecord::Base
|
||||
|
||||
USERNAME_FORMAT = /\A[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\z/
|
||||
USERNAME_FORMAT = /\A[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]\z/
|
||||
|
||||
has_many :api_tokens, :dependent => :destroy
|
||||
has_many :asciicasts, :dependent => :destroy
|
||||
@ -13,7 +13,7 @@ class User < ActiveRecord::Base
|
||||
validates :username, presence: true
|
||||
validates :username, uniqueness: { scope: :dummy, case_sensitive: false },
|
||||
format: { with: USERNAME_FORMAT },
|
||||
length: { minimum: 3, maximum: 16 },
|
||||
length: { minimum: 2, maximum: 16 },
|
||||
unless: :dummy
|
||||
validates :email, presence: true, uniqueness: true, unless: :dummy
|
||||
|
||||
|
@ -51,13 +51,13 @@ describe User do
|
||||
|
||||
it { should allow_value('sickill').for(:username) }
|
||||
it { should allow_value('sick-ill').for(:username) }
|
||||
it { should allow_value('abc').for(:username) }
|
||||
it { should allow_value('ab').for(:username) }
|
||||
it { should allow_value('s' * 16).for(:username) }
|
||||
it { should allow_value('Sickill').for(:username) }
|
||||
it { should_not allow_value('sick.ill').for(:username) }
|
||||
it { should_not allow_value('-sickill').for(:username) }
|
||||
it { should_not allow_value('sickill-').for(:username) }
|
||||
it { should_not allow_value('ab').for(:username) }
|
||||
it { should_not allow_value('a').for(:username) }
|
||||
it { should_not allow_value('s' * 17).for(:username) }
|
||||
|
||||
it "checks username uniqueness" do
|
||||
|
Loading…
Reference in New Issue
Block a user