summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/user.rb3
-rw-r--r--spec/models/user_spec.rb6
2 files changed, 8 insertions, 1 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 30b3fecd..c455162a 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -16,6 +16,7 @@ class User < ActiveRecord::Base
validates :name, :presence => true
validates :email, presence: true, uniqueness: true, email: true
validates :website, :format => URI::regexp(%w(http https)), :allow_blank => true
+ validates :password, length: { in: 6..20 }
#devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :token_authenticatable
has_many :creations, :dependent => :destroy
@@ -47,7 +48,7 @@ class User < ActiveRecord::Base
end
def password
- @password ||= Password.new(password_hash)
+ @password ||= Password.new(encrypted_password)
end
def password=(new_password)
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 14f32a3d..5a7e95de 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -32,6 +32,12 @@ describe User do
expect(subject.valid?).to be_falsey
expect(subject.errors[:email]).to_not be_empty
end
+
+ it 'validates the presence of a password' do
+ subject.password = nil
+ expect(subject.valid?).to be_falsey
+ expect(subject.errors[:password]).to_not be_empty
+ end
end
describe "when a website url is supplied" do