improve user email validation
This commit is contained in:
committed by
Pete Matsyburka
parent
8b9678a434
commit
fa0733f480
@@ -33,6 +33,14 @@ RSpec.describe 'Profile Settings' do
|
||||
expect(user.last_name).to eq('Beckham')
|
||||
expect(user.email).to eq('david.beckham@example.com')
|
||||
end
|
||||
|
||||
it 'does not update if email is invalid' do
|
||||
fill_in 'Email', with: 'devid+test@example'
|
||||
|
||||
all(:button, 'Update')[0].click
|
||||
|
||||
expect(page).to have_content('Email is invalid')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when changes password' do
|
||||
|
||||
@@ -51,6 +51,16 @@ RSpec.describe 'App Setup' do
|
||||
end
|
||||
|
||||
context 'when invalid information' do
|
||||
it 'does not setup the app if the email is invalid' do
|
||||
fill_setup_form(form_data.merge(email: 'bob@example-com'))
|
||||
|
||||
expect do
|
||||
click_button 'Submit'
|
||||
end.not_to(change(User, :count))
|
||||
|
||||
expect(page).to have_content('Email is invalid')
|
||||
end
|
||||
|
||||
it 'does not setup the app if the password is too short' do
|
||||
fill_setup_form(form_data.merge(password: 'pass'))
|
||||
|
||||
|
||||
@@ -92,6 +92,23 @@ RSpec.describe 'Team Settings' do
|
||||
end
|
||||
end
|
||||
|
||||
it 'does not allow to create a new user with an invalid email' do
|
||||
click_link 'New User'
|
||||
|
||||
within '#modal' do
|
||||
fill_in 'First name', with: 'Joseph'
|
||||
fill_in 'Last name', with: 'Smith'
|
||||
fill_in 'Email', with: 'joseph.smith@gmail'
|
||||
fill_in 'Password', with: 'password'
|
||||
|
||||
expect do
|
||||
click_button 'Submit'
|
||||
end.not_to change(User, :count)
|
||||
|
||||
expect(page).to have_content('Email is invalid')
|
||||
end
|
||||
end
|
||||
|
||||
it 'updates a user' do
|
||||
first(:link, 'Edit').click
|
||||
|
||||
|
||||
Reference in New Issue
Block a user