Improve User specs about email uniqueness
This commit is contained in:
parent
0e3cf48d95
commit
5e6781a656
@ -11,11 +11,12 @@ describe User do
|
|||||||
it { should validate_presence_of :password_hash }
|
it { should validate_presence_of :password_hash }
|
||||||
|
|
||||||
context 'when a user with the same email address already exists' do
|
context 'when a user with the same email address already exists' do
|
||||||
it 'should not be valid' do
|
let(:old_user) { Factory.create(:user, :email => 'unique@example.net') }
|
||||||
user = Factory.create(:user, :email => 'unique@example.net')
|
subject { Factory.build(:user, :email => old_user.email) }
|
||||||
new_user = Factory.build(:user, :email => user.email)
|
|
||||||
new_user.should_not be_valid
|
it { should_not be_valid }
|
||||||
end
|
|
||||||
|
it { should have(1).error_on(:email) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when password_confirmation does not match password' do
|
context 'when password_confirmation does not match password' do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user