Validate uniqueness of user email address
* Make user.email attribute unique * Render validations error messages in users/new view
This commit is contained in:
@@ -32,6 +32,14 @@ describe User do
|
||||
it { should_not be_valid }
|
||||
end
|
||||
|
||||
context 'when a user with the same email address already exists' do
|
||||
it 'should not be valid' do
|
||||
user = Factory.create(:user, :email => 'unique@example.net')
|
||||
new_user = Factory.build(:user, :email => user.email)
|
||||
new_user.should_not be_valid
|
||||
end
|
||||
end
|
||||
|
||||
describe '#password=' do
|
||||
it 'stores a bcrypt hash of the password in password_hash' do
|
||||
BCrypt::Password.new(user.password_hash).should == user.password
|
||||
|
Reference in New Issue
Block a user