2013-02-21 06:09:47 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2016-09-09 08:21:00 -04:00
|
|
|
feature 'Users', feature: true, js: true do
|
2015-09-29 12:08:55 -04:00
|
|
|
let(:user) { create(:user, username: 'user1', name: 'User 1', email: 'user1@gitlab.com') }
|
2015-09-28 10:00:53 -04:00
|
|
|
|
2015-04-08 14:26:04 -04:00
|
|
|
scenario 'GET /users/sign_in creates a new user account' do
|
|
|
|
visit new_user_session_path
|
2016-09-09 08:21:00 -04:00
|
|
|
click_link 'Register'
|
2016-11-11 19:47:32 -05:00
|
|
|
fill_in 'new_user_name', with: 'Name Surname'
|
|
|
|
fill_in 'new_user_username', with: 'Great'
|
|
|
|
fill_in 'new_user_email', with: 'name@mail.com'
|
|
|
|
fill_in 'new_user_email_confirmation', with: 'name@mail.com'
|
|
|
|
fill_in 'new_user_password', with: 'password1234'
|
2016-09-09 08:21:00 -04:00
|
|
|
expect { click_button 'Register' }.to change { User.count }.by(1)
|
2015-04-08 14:26:04 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'Successful user signin invalidates password reset token' do
|
|
|
|
expect(user.reset_password_token).to be_nil
|
|
|
|
|
|
|
|
visit new_user_password_path
|
|
|
|
fill_in 'user_email', with: user.email
|
|
|
|
click_button 'Reset password'
|
|
|
|
|
|
|
|
user.reload
|
|
|
|
expect(user.reset_password_token).not_to be_nil
|
|
|
|
|
2017-06-05 14:51:54 -04:00
|
|
|
gitlab_sign_in(user)
|
2015-04-08 14:26:04 -04:00
|
|
|
expect(current_path).to eq root_path
|
|
|
|
|
|
|
|
user.reload
|
|
|
|
expect(user.reset_password_token).to be_nil
|
2013-02-21 06:09:47 -05:00
|
|
|
end
|
2015-06-15 11:35:41 -04:00
|
|
|
|
|
|
|
scenario 'Should show one error if email is already taken' do
|
|
|
|
visit new_user_session_path
|
2016-09-09 08:21:00 -04:00
|
|
|
click_link 'Register'
|
2016-11-11 19:47:32 -05:00
|
|
|
fill_in 'new_user_name', with: 'Another user name'
|
|
|
|
fill_in 'new_user_username', with: 'anotheruser'
|
|
|
|
fill_in 'new_user_email', with: user.email
|
|
|
|
fill_in 'new_user_email_confirmation', with: user.email
|
|
|
|
fill_in 'new_user_password', with: '12341234'
|
2016-09-09 08:21:00 -04:00
|
|
|
expect { click_button 'Register' }.to change { User.count }.by(0)
|
2015-06-15 11:35:41 -04:00
|
|
|
expect(page).to have_text('Email has already been taken')
|
|
|
|
expect(number_of_errors_on_page(page)).to be(1), 'errors on page:\n #{errors_on_page page}'
|
|
|
|
end
|
|
|
|
|
2016-10-06 08:14:24 -04:00
|
|
|
describe 'redirect alias routes' do
|
2017-06-14 14:18:56 -04:00
|
|
|
before do
|
|
|
|
expect(user).to be_persisted
|
|
|
|
end
|
2016-10-06 08:14:24 -04:00
|
|
|
|
|
|
|
scenario '/u/user1 redirects to user page' do
|
|
|
|
visit '/u/user1'
|
|
|
|
|
2016-10-06 08:34:30 -04:00
|
|
|
expect(current_path).to eq user_path(user)
|
|
|
|
expect(page).to have_text(user.name)
|
2016-10-06 08:14:24 -04:00
|
|
|
end
|
2016-10-13 07:11:26 -04:00
|
|
|
|
|
|
|
scenario '/u/user1/groups redirects to user groups page' do
|
|
|
|
visit '/u/user1/groups'
|
|
|
|
|
|
|
|
expect(current_path).to eq user_groups_path(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario '/u/user1/projects redirects to user projects page' do
|
|
|
|
visit '/u/user1/projects'
|
|
|
|
|
|
|
|
expect(current_path).to eq user_projects_path(user)
|
|
|
|
end
|
2016-10-06 08:14:24 -04:00
|
|
|
end
|
|
|
|
|
2016-09-09 08:21:00 -04:00
|
|
|
feature 'username validation' do
|
|
|
|
let(:loading_icon) { '.fa.fa-spinner' }
|
|
|
|
let(:username_input) { 'new_user_username' }
|
|
|
|
|
|
|
|
before(:each) do
|
|
|
|
visit new_user_session_path
|
|
|
|
click_link 'Register'
|
|
|
|
end
|
2016-11-16 07:24:43 -05:00
|
|
|
|
|
|
|
scenario 'doesn\'t show an error border if the username is available' do
|
|
|
|
fill_in username_input, with: 'new-user'
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2016-11-16 07:24:43 -05:00
|
|
|
expect(find('.username')).not_to have_css '.gl-field-error-outline'
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'does not show an error border if the username contains dots (.)' do
|
|
|
|
fill_in username_input, with: 'new.user.username'
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2016-11-16 07:24:43 -05:00
|
|
|
expect(find('.username')).not_to have_css '.gl-field-error-outline'
|
|
|
|
end
|
|
|
|
|
2016-09-27 08:54:15 -04:00
|
|
|
scenario 'shows an error border if the username already exists' do
|
2016-09-09 08:21:00 -04:00
|
|
|
fill_in username_input, with: user.username
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2016-10-13 11:59:55 -04:00
|
|
|
expect(find('.username')).to have_css '.gl-field-error-outline'
|
2016-09-09 08:21:00 -04:00
|
|
|
end
|
|
|
|
|
2016-11-16 07:24:43 -05:00
|
|
|
scenario 'shows an error border if the username contains special characters' do
|
|
|
|
fill_in username_input, with: 'new$user!username'
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2016-11-16 07:24:43 -05:00
|
|
|
expect(find('.username')).to have_css '.gl-field-error-outline'
|
2016-09-09 08:21:00 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-06-15 11:35:41 -04:00
|
|
|
def errors_on_page(page)
|
|
|
|
page.find('#error_explanation').find('ul').all('li').map{ |item| item.text }.join("\n")
|
|
|
|
end
|
|
|
|
|
|
|
|
def number_of_errors_on_page(page)
|
|
|
|
page.find('#error_explanation').find('ul').all('li').count
|
|
|
|
end
|
2013-02-21 06:09:47 -05:00
|
|
|
end
|