Save user password as a bcrypt hash
* Replace password field by password_hash * Add User#password attribute * Implement password hashing and verification with BCrypt mixin
This commit is contained in:
@@ -24,6 +24,26 @@ describe User do
|
||||
it { should_not be_valid }
|
||||
end
|
||||
|
||||
context 'when password_confirmation does not match password' do
|
||||
before do
|
||||
user.password_confirmation = 'WRONG'
|
||||
end
|
||||
|
||||
it { should_not be_valid }
|
||||
end
|
||||
|
||||
describe '#hash_password' do
|
||||
it 'is received when #save is sent' do
|
||||
user.should_receive(:hash_password)
|
||||
user.save
|
||||
end
|
||||
|
||||
it 'stores a bcrypt hash of the password' do
|
||||
user.save
|
||||
BCrypt::Password.new(user.password_hash).should == user.password
|
||||
end
|
||||
end
|
||||
|
||||
describe '.authenticate' do
|
||||
let (:user) { Factory.create(:user) }
|
||||
|
||||
|
Reference in New Issue
Block a user