2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-02-22 06:44:14 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.shared_examples 'Signup' do
|
2018-04-27 10:50:33 -04:00
|
|
|
include TermsHelper
|
|
|
|
|
2018-02-22 06:44:14 -05:00
|
|
|
let(:new_user) { build_stubbed(:user) }
|
|
|
|
|
|
|
|
describe 'username validation', :js do
|
|
|
|
before do
|
2019-10-07 11:05:59 -04:00
|
|
|
visit new_user_registration_path
|
2018-02-22 06:44:14 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not show an error border if the username is available' do
|
|
|
|
fill_in 'new_user_username', with: 'new-user'
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(find('.username')).not_to have_css '.gl-field-error-outline'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not show an error border if the username contains dots (.)' do
|
2019-06-19 09:48:30 -04:00
|
|
|
simulate_input('#new_user_username', 'new.user.username')
|
2018-02-22 06:44:14 -05:00
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(find('.username')).not_to have_css '.gl-field-error-outline'
|
|
|
|
end
|
|
|
|
|
2019-06-06 03:39:59 -04:00
|
|
|
it 'does not show an error border if the username length is not longer than 255 characters' do
|
|
|
|
fill_in 'new_user_username', with: 'u' * 255
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(find('.username')).not_to have_css '.gl-field-error-outline'
|
|
|
|
end
|
|
|
|
|
2018-02-22 06:44:14 -05:00
|
|
|
it 'shows an error border if the username already exists' do
|
|
|
|
existing_user = create(:user)
|
|
|
|
|
|
|
|
fill_in 'new_user_username', with: existing_user.username
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(find('.username')).to have_css '.gl-field-error-outline'
|
|
|
|
end
|
|
|
|
|
2019-06-19 09:48:30 -04:00
|
|
|
it 'shows a success border if the username is available' do
|
|
|
|
fill_in 'new_user_username', with: 'new-user'
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(find('.username')).to have_css '.gl-field-success-outline'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows an error border if the username contains special characters' do
|
2018-02-22 06:44:14 -05:00
|
|
|
fill_in 'new_user_username', with: 'new$user!username'
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(find('.username')).to have_css '.gl-field-error-outline'
|
|
|
|
end
|
2018-06-24 06:51:07 -04:00
|
|
|
|
2019-06-06 03:39:59 -04:00
|
|
|
it 'shows an error border if the username is longer than 255 characters' do
|
|
|
|
fill_in 'new_user_username', with: 'u' * 256
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(find('.username')).to have_css '.gl-field-error-outline'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows an error message if the username is longer than 255 characters' do
|
|
|
|
fill_in 'new_user_username', with: 'u' * 256
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).to have_content("Username is too long (maximum is 255 characters).")
|
|
|
|
end
|
|
|
|
|
2020-07-06 05:09:20 -04:00
|
|
|
it 'shows an error message if the username is less than 2 characters' do
|
|
|
|
fill_in 'new_user_username', with: 'u'
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).to have_content("Username is too short (minimum is 2 characters).")
|
|
|
|
end
|
|
|
|
|
2018-06-24 06:51:07 -04:00
|
|
|
it 'shows an error message on submit if the username contains special characters' do
|
|
|
|
fill_in 'new_user_username', with: 'new$user!username'
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
click_button "Register"
|
|
|
|
|
|
|
|
expect(page).to have_content("Please create a username with only alphanumeric characters.")
|
|
|
|
end
|
2019-02-18 03:40:07 -05:00
|
|
|
|
2019-06-19 09:48:30 -04:00
|
|
|
it 'shows an error border if the username contains emojis' do
|
2019-02-18 03:40:07 -05:00
|
|
|
simulate_input('#new_user_username', 'ehsan😀')
|
|
|
|
|
|
|
|
expect(find('.username')).to have_css '.gl-field-error-outline'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows an error message if the username contains emojis' do
|
|
|
|
simulate_input('#new_user_username', 'ehsan😀')
|
|
|
|
|
|
|
|
expect(page).to have_content("Invalid input, please avoid emojis")
|
|
|
|
end
|
2019-06-19 09:48:30 -04:00
|
|
|
|
2020-07-08 02:09:13 -04:00
|
|
|
it 'shows a pending message if the username availability is being fetched', quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/31484' do
|
2019-06-19 09:48:30 -04:00
|
|
|
fill_in 'new_user_username', with: 'new-user'
|
|
|
|
|
|
|
|
expect(find('.username > .validation-pending')).not_to have_css '.hide'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows a success message if the username is available' do
|
|
|
|
fill_in 'new_user_username', with: 'new-user'
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(find('.username > .validation-success')).not_to have_css '.hide'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows an error message if the username is unavailable' do
|
|
|
|
existing_user = create(:user)
|
|
|
|
|
|
|
|
fill_in 'new_user_username', with: existing_user.username
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(find('.username > .validation-error')).not_to have_css '.hide'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows a success message if the username is corrected and then available' do
|
|
|
|
fill_in 'new_user_username', with: 'new-user$'
|
|
|
|
wait_for_requests
|
|
|
|
fill_in 'new_user_username', with: 'new-user'
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).to have_content("Username is available.")
|
|
|
|
end
|
2019-02-18 03:40:07 -05:00
|
|
|
end
|
|
|
|
|
2018-02-22 06:44:14 -05:00
|
|
|
context 'with no errors' do
|
2019-07-31 10:49:52 -04:00
|
|
|
context 'when sending confirmation email' do
|
2018-02-22 06:44:14 -05:00
|
|
|
before do
|
|
|
|
stub_application_setting(send_user_confirmation_email: true)
|
|
|
|
end
|
|
|
|
|
2020-03-11 20:09:34 -04:00
|
|
|
context 'when soft email confirmation is not enabled' do
|
|
|
|
before do
|
|
|
|
stub_feature_flags(soft_email_confirmation: false)
|
|
|
|
end
|
2019-07-31 10:49:52 -04:00
|
|
|
|
2020-03-11 20:09:34 -04:00
|
|
|
it 'creates the user account and sends a confirmation email' do
|
|
|
|
visit new_user_registration_path
|
2019-07-31 10:49:52 -04:00
|
|
|
|
2020-03-11 20:09:34 -04:00
|
|
|
fill_in 'new_user_username', with: new_user.username
|
|
|
|
fill_in 'new_user_email', with: new_user.email
|
|
|
|
|
|
|
|
if Gitlab::Experimentation.enabled?(:signup_flow)
|
|
|
|
fill_in 'new_user_first_name', with: new_user.first_name
|
|
|
|
fill_in 'new_user_last_name', with: new_user.last_name
|
|
|
|
else
|
|
|
|
fill_in 'new_user_name', with: new_user.name
|
|
|
|
fill_in 'new_user_email_confirmation', with: new_user.email
|
|
|
|
end
|
|
|
|
|
|
|
|
fill_in 'new_user_password', with: new_user.password
|
|
|
|
|
|
|
|
expect { click_button 'Register' }.to change { User.count }.by(1)
|
|
|
|
|
|
|
|
expect(current_path).to eq users_almost_there_path
|
|
|
|
expect(page).to have_content('Please check your email to confirm your account')
|
2019-07-31 10:49:52 -04:00
|
|
|
end
|
2020-03-11 20:09:34 -04:00
|
|
|
end
|
2019-07-31 10:49:52 -04:00
|
|
|
|
2020-03-11 20:09:34 -04:00
|
|
|
context 'when soft email confirmation is enabled' do
|
|
|
|
before do
|
|
|
|
stub_feature_flags(soft_email_confirmation: true)
|
|
|
|
end
|
2018-02-22 06:44:14 -05:00
|
|
|
|
2020-03-11 20:09:34 -04:00
|
|
|
it 'creates the user account and sends a confirmation email' do
|
|
|
|
visit new_user_registration_path
|
2018-02-22 06:44:14 -05:00
|
|
|
|
2020-03-11 20:09:34 -04:00
|
|
|
fill_in 'new_user_username', with: new_user.username
|
|
|
|
fill_in 'new_user_email', with: new_user.email
|
|
|
|
|
|
|
|
if Gitlab::Experimentation.enabled?(:signup_flow)
|
|
|
|
fill_in 'new_user_first_name', with: new_user.first_name
|
|
|
|
fill_in 'new_user_last_name', with: new_user.last_name
|
|
|
|
else
|
|
|
|
fill_in 'new_user_name', with: new_user.name
|
|
|
|
fill_in 'new_user_email_confirmation', with: new_user.email
|
|
|
|
end
|
|
|
|
|
|
|
|
fill_in 'new_user_password', with: new_user.password
|
|
|
|
|
|
|
|
expect { click_button 'Register' }.to change { User.count }.by(1)
|
|
|
|
|
|
|
|
if Gitlab::Experimentation.enabled?(:signup_flow)
|
|
|
|
expect(current_path).to eq users_sign_up_welcome_path
|
|
|
|
else
|
|
|
|
expect(current_path).to eq dashboard_projects_path
|
|
|
|
expect(page).to have_content("Please check your email (#{new_user.email}) to verify that you own this address and unlock the power of CI/CD.")
|
|
|
|
end
|
2019-07-31 10:49:52 -04:00
|
|
|
end
|
2018-02-22 06:44:14 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when sigining up with different cased emails" do
|
|
|
|
it "creates the user successfully" do
|
2019-10-07 11:05:59 -04:00
|
|
|
visit new_user_registration_path
|
2018-02-22 06:44:14 -05:00
|
|
|
|
2019-10-07 11:05:59 -04:00
|
|
|
fill_in 'new_user_username', with: new_user.username
|
|
|
|
fill_in 'new_user_email', with: new_user.email
|
|
|
|
|
2020-01-17 04:08:24 -05:00
|
|
|
if Gitlab::Experimentation.enabled?(:signup_flow)
|
|
|
|
fill_in 'new_user_first_name', with: new_user.first_name
|
|
|
|
fill_in 'new_user_last_name', with: new_user.last_name
|
|
|
|
else
|
2019-10-18 17:06:37 -04:00
|
|
|
fill_in 'new_user_name', with: new_user.name
|
2019-10-07 11:05:59 -04:00
|
|
|
fill_in 'new_user_email_confirmation', with: new_user.email.capitalize
|
|
|
|
end
|
|
|
|
|
|
|
|
fill_in 'new_user_password', with: new_user.password
|
2018-02-22 06:44:14 -05:00
|
|
|
click_button "Register"
|
|
|
|
|
2019-10-18 17:06:37 -04:00
|
|
|
if Gitlab::Experimentation.enabled?(:signup_flow)
|
|
|
|
expect(current_path).to eq users_sign_up_welcome_path
|
|
|
|
else
|
|
|
|
expect(current_path).to eq dashboard_projects_path
|
|
|
|
expect(page).to have_content("Welcome! You have signed up successfully.")
|
|
|
|
end
|
2018-02-22 06:44:14 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when not sending confirmation email" do
|
|
|
|
before do
|
|
|
|
stub_application_setting(send_user_confirmation_email: false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates the user account and goes to dashboard' do
|
2019-10-07 11:05:59 -04:00
|
|
|
visit new_user_registration_path
|
|
|
|
|
|
|
|
fill_in 'new_user_username', with: new_user.username
|
|
|
|
fill_in 'new_user_email', with: new_user.email
|
2018-02-22 06:44:14 -05:00
|
|
|
|
2020-01-17 04:08:24 -05:00
|
|
|
if Gitlab::Experimentation.enabled?(:signup_flow)
|
|
|
|
fill_in 'new_user_first_name', with: new_user.first_name
|
|
|
|
fill_in 'new_user_last_name', with: new_user.last_name
|
|
|
|
else
|
2019-10-18 17:06:37 -04:00
|
|
|
fill_in 'new_user_name', with: new_user.name
|
2019-10-07 11:05:59 -04:00
|
|
|
fill_in 'new_user_email_confirmation', with: new_user.email
|
|
|
|
end
|
|
|
|
|
|
|
|
fill_in 'new_user_password', with: new_user.password
|
2018-02-22 06:44:14 -05:00
|
|
|
click_button "Register"
|
|
|
|
|
2019-10-18 17:06:37 -04:00
|
|
|
if Gitlab::Experimentation.enabled?(:signup_flow)
|
|
|
|
expect(current_path).to eq users_sign_up_welcome_path
|
|
|
|
else
|
|
|
|
expect(current_path).to eq dashboard_projects_path
|
|
|
|
expect(page).to have_content("Welcome! You have signed up successfully.")
|
|
|
|
end
|
2018-02-22 06:44:14 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with errors' do
|
|
|
|
it "displays the errors" do
|
|
|
|
existing_user = create(:user)
|
|
|
|
|
2019-10-07 11:05:59 -04:00
|
|
|
visit new_user_registration_path
|
2018-02-22 06:44:14 -05:00
|
|
|
|
2020-01-17 04:08:24 -05:00
|
|
|
if Gitlab::Experimentation.enabled?(:signup_flow)
|
|
|
|
fill_in 'new_user_first_name', with: new_user.first_name
|
|
|
|
fill_in 'new_user_last_name', with: new_user.last_name
|
|
|
|
else
|
2019-10-18 17:06:37 -04:00
|
|
|
fill_in 'new_user_name', with: new_user.name
|
|
|
|
end
|
|
|
|
|
2018-02-22 06:44:14 -05:00
|
|
|
fill_in 'new_user_username', with: new_user.username
|
2019-10-07 11:05:59 -04:00
|
|
|
fill_in 'new_user_email', with: existing_user.email
|
2018-02-22 06:44:14 -05:00
|
|
|
fill_in 'new_user_password', with: new_user.password
|
|
|
|
click_button "Register"
|
|
|
|
|
|
|
|
expect(current_path).to eq user_registration_path
|
2019-10-07 11:05:59 -04:00
|
|
|
|
2019-10-18 17:06:37 -04:00
|
|
|
if Gitlab::Experimentation.enabled?(:signup_flow)
|
2019-10-07 11:05:59 -04:00
|
|
|
expect(page).to have_content("error prohibited this user from being saved")
|
|
|
|
else
|
|
|
|
expect(page).to have_content("errors prohibited this user from being saved")
|
|
|
|
expect(page).to have_content("Email confirmation doesn't match")
|
|
|
|
end
|
2019-10-18 17:06:37 -04:00
|
|
|
|
|
|
|
expect(page).to have_content("Email has already been taken")
|
2018-02-22 06:44:14 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not redisplay the password' do
|
|
|
|
existing_user = create(:user)
|
|
|
|
|
2019-10-07 11:05:59 -04:00
|
|
|
visit new_user_registration_path
|
2018-02-22 06:44:14 -05:00
|
|
|
|
2020-01-17 04:08:24 -05:00
|
|
|
if Gitlab::Experimentation.enabled?(:signup_flow)
|
|
|
|
fill_in 'new_user_first_name', with: new_user.first_name
|
|
|
|
fill_in 'new_user_last_name', with: new_user.last_name
|
|
|
|
else
|
2019-10-18 17:06:37 -04:00
|
|
|
fill_in 'new_user_name', with: new_user.name
|
|
|
|
end
|
|
|
|
|
2018-02-22 06:44:14 -05:00
|
|
|
fill_in 'new_user_username', with: new_user.username
|
2019-10-07 11:05:59 -04:00
|
|
|
fill_in 'new_user_email', with: existing_user.email
|
2018-02-22 06:44:14 -05:00
|
|
|
fill_in 'new_user_password', with: new_user.password
|
|
|
|
click_button "Register"
|
|
|
|
|
|
|
|
expect(current_path).to eq user_registration_path
|
|
|
|
expect(page.body).not_to match(/#{new_user.password}/)
|
|
|
|
end
|
|
|
|
end
|
2018-04-27 10:50:33 -04:00
|
|
|
|
|
|
|
context 'when terms are enforced' do
|
|
|
|
before do
|
|
|
|
enforce_terms
|
|
|
|
end
|
|
|
|
|
2018-06-08 07:20:44 -04:00
|
|
|
it 'requires the user to check the checkbox' do
|
2019-10-07 11:05:59 -04:00
|
|
|
visit new_user_registration_path
|
|
|
|
|
|
|
|
fill_in 'new_user_username', with: new_user.username
|
|
|
|
fill_in 'new_user_email', with: new_user.email
|
|
|
|
|
2020-01-17 04:08:24 -05:00
|
|
|
if Gitlab::Experimentation.enabled?(:signup_flow)
|
|
|
|
fill_in 'new_user_first_name', with: new_user.first_name
|
|
|
|
fill_in 'new_user_last_name', with: new_user.last_name
|
|
|
|
else
|
2019-10-18 17:06:37 -04:00
|
|
|
fill_in 'new_user_name', with: new_user.name
|
2019-10-07 11:05:59 -04:00
|
|
|
fill_in 'new_user_email_confirmation', with: new_user.email
|
|
|
|
end
|
2018-04-27 10:50:33 -04:00
|
|
|
|
2019-10-07 11:05:59 -04:00
|
|
|
fill_in 'new_user_password', with: new_user.password
|
2018-04-27 10:50:33 -04:00
|
|
|
|
2018-06-08 07:20:44 -04:00
|
|
|
click_button 'Register'
|
|
|
|
|
|
|
|
expect(current_path).to eq new_user_session_path
|
|
|
|
expect(page).to have_content(/you must accept our terms of service/i)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'asks the user to accept terms before going to the dashboard' do
|
2019-10-07 11:05:59 -04:00
|
|
|
visit new_user_registration_path
|
|
|
|
|
|
|
|
fill_in 'new_user_username', with: new_user.username
|
|
|
|
fill_in 'new_user_email', with: new_user.email
|
|
|
|
|
2020-01-17 04:08:24 -05:00
|
|
|
if Gitlab::Experimentation.enabled?(:signup_flow)
|
|
|
|
fill_in 'new_user_first_name', with: new_user.first_name
|
|
|
|
fill_in 'new_user_last_name', with: new_user.last_name
|
|
|
|
else
|
2019-10-18 17:06:37 -04:00
|
|
|
fill_in 'new_user_name', with: new_user.name
|
2019-10-07 11:05:59 -04:00
|
|
|
fill_in 'new_user_email_confirmation', with: new_user.email
|
|
|
|
end
|
2018-06-08 07:20:44 -04:00
|
|
|
|
2019-10-07 11:05:59 -04:00
|
|
|
fill_in 'new_user_password', with: new_user.password
|
2018-06-08 07:20:44 -04:00
|
|
|
check :terms_opt_in
|
2018-04-27 10:50:33 -04:00
|
|
|
|
2018-06-08 07:20:44 -04:00
|
|
|
click_button "Register"
|
2018-04-27 10:50:33 -04:00
|
|
|
|
2019-10-18 17:06:37 -04:00
|
|
|
if Gitlab::Experimentation.enabled?(:signup_flow)
|
|
|
|
expect(current_path).to eq users_sign_up_welcome_path
|
|
|
|
else
|
|
|
|
expect(current_path).to eq dashboard_projects_path
|
|
|
|
end
|
2018-04-27 10:50:33 -04:00
|
|
|
end
|
|
|
|
end
|
2019-10-07 11:05:59 -04:00
|
|
|
|
2019-10-18 17:06:37 -04:00
|
|
|
context 'when reCAPTCHA and invisible captcha are enabled' do
|
2019-10-07 11:05:59 -04:00
|
|
|
before do
|
2019-10-18 17:06:37 -04:00
|
|
|
InvisibleCaptcha.timestamp_enabled = true
|
|
|
|
stub_application_setting(recaptcha_enabled: true)
|
2019-11-13 22:06:25 -05:00
|
|
|
allow_next_instance_of(RegistrationsController) do |instance|
|
2020-02-04 07:09:00 -05:00
|
|
|
allow(instance).to receive(:verify_recaptcha).and_return(true)
|
2019-11-13 22:06:25 -05:00
|
|
|
end
|
2019-10-18 17:06:37 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
after do
|
|
|
|
InvisibleCaptcha.timestamp_enabled = false
|
|
|
|
end
|
|
|
|
|
2020-02-04 07:09:00 -05:00
|
|
|
context 'when reCAPTCHA detects malicious behaviour' do
|
|
|
|
before do
|
|
|
|
allow_next_instance_of(RegistrationsController) do |instance|
|
|
|
|
allow(instance).to receive(:verify_recaptcha).and_return(false)
|
|
|
|
end
|
|
|
|
end
|
2019-10-18 17:06:37 -04:00
|
|
|
|
2020-02-04 07:09:00 -05:00
|
|
|
it 'prevents from signing up' do
|
|
|
|
visit new_user_registration_path
|
2019-10-18 17:06:37 -04:00
|
|
|
|
2020-02-04 07:09:00 -05:00
|
|
|
fill_in 'new_user_username', with: new_user.username
|
|
|
|
fill_in 'new_user_email', with: new_user.email
|
|
|
|
|
|
|
|
if Gitlab::Experimentation.enabled?(:signup_flow)
|
|
|
|
fill_in 'new_user_first_name', with: new_user.first_name
|
|
|
|
fill_in 'new_user_last_name', with: new_user.last_name
|
|
|
|
else
|
|
|
|
fill_in 'new_user_name', with: new_user.name
|
|
|
|
fill_in 'new_user_email_confirmation', with: new_user.email
|
|
|
|
end
|
|
|
|
|
|
|
|
fill_in 'new_user_password', with: new_user.password
|
|
|
|
|
|
|
|
expect { click_button 'Register' }.not_to change { User.count }
|
|
|
|
expect(page).to have_content('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.')
|
2019-10-18 17:06:37 -04:00
|
|
|
end
|
2020-02-04 07:09:00 -05:00
|
|
|
end
|
2019-10-18 17:06:37 -04:00
|
|
|
|
2020-02-04 07:09:00 -05:00
|
|
|
context 'when invisible captcha detects malicious behaviour' do
|
|
|
|
it 'prevents from signing up' do
|
|
|
|
visit new_user_registration_path
|
2019-10-18 17:06:37 -04:00
|
|
|
|
2020-02-04 07:09:00 -05:00
|
|
|
fill_in 'new_user_username', with: new_user.username
|
|
|
|
fill_in 'new_user_email', with: new_user.email
|
2019-10-18 17:06:37 -04:00
|
|
|
|
2020-02-04 07:09:00 -05:00
|
|
|
if Gitlab::Experimentation.enabled?(:signup_flow)
|
|
|
|
fill_in 'new_user_first_name', with: new_user.first_name
|
|
|
|
fill_in 'new_user_last_name', with: new_user.last_name
|
|
|
|
else
|
|
|
|
fill_in 'new_user_name', with: new_user.name
|
|
|
|
fill_in 'new_user_email_confirmation', with: new_user.email
|
|
|
|
end
|
|
|
|
|
|
|
|
fill_in 'new_user_password', with: new_user.password
|
|
|
|
|
|
|
|
expect { click_button 'Register' }.not_to change { User.count }
|
2019-10-18 17:06:37 -04:00
|
|
|
expect(page).to have_content('That was a bit too quick! Please resubmit.')
|
|
|
|
end
|
2019-10-07 11:05:59 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.shared_examples 'Signup name validation' do |field, max_length|
|
2020-01-17 04:08:24 -05:00
|
|
|
before do
|
|
|
|
visit new_user_registration_path
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "#{field} validation", :js do
|
|
|
|
it "does not show an error border if the user's fullname length is not longer than #{max_length} characters" do
|
|
|
|
fill_in field, with: 'u' * max_length
|
|
|
|
|
|
|
|
expect(find('.name')).not_to have_css '.gl-field-error-outline'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows an error border if the user\'s fullname contains an emoji' do
|
|
|
|
simulate_input("##{field}", 'Ehsan 🦋')
|
|
|
|
|
|
|
|
expect(find('.name')).to have_css '.gl-field-error-outline'
|
|
|
|
end
|
|
|
|
|
|
|
|
it "shows an error border if the user\'s fullname is longer than #{max_length} characters" do
|
|
|
|
fill_in field, with: 'n' * (max_length + 1)
|
|
|
|
|
|
|
|
expect(find('.name')).to have_css '.gl-field-error-outline'
|
|
|
|
end
|
|
|
|
|
|
|
|
it "shows an error message if the user\'s fullname is longer than #{max_length} characters" do
|
|
|
|
fill_in field, with: 'n' * (max_length + 1)
|
|
|
|
|
|
|
|
expect(page).to have_content("Name is too long (maximum is #{max_length} characters).")
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows an error message if the username contains emojis' do
|
|
|
|
simulate_input("##{field}", 'Ehsan 🦋')
|
|
|
|
|
|
|
|
expect(page).to have_content("Invalid input, please avoid emojis")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'With original flow' do
|
2019-10-18 17:06:37 -04:00
|
|
|
before do
|
|
|
|
stub_experiment(signup_flow: false)
|
2019-10-23 11:06:29 -04:00
|
|
|
stub_experiment_for_user(signup_flow: false)
|
2019-10-18 17:06:37 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'Signup'
|
2020-01-17 04:08:24 -05:00
|
|
|
it_behaves_like 'Signup name validation', 'new_user_name', 255
|
2019-10-18 17:06:37 -04:00
|
|
|
end
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'With experimental flow' do
|
2019-10-18 17:06:37 -04:00
|
|
|
before do
|
2020-04-30 08:09:45 -04:00
|
|
|
stub_experiment(signup_flow: true)
|
|
|
|
stub_experiment_for_user(signup_flow: true)
|
2019-10-18 17:06:37 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'Signup'
|
2020-01-17 04:08:24 -05:00
|
|
|
it_behaves_like 'Signup name validation', 'new_user_first_name', 127
|
|
|
|
it_behaves_like 'Signup name validation', 'new_user_last_name', 127
|
2019-10-18 17:06:37 -04:00
|
|
|
|
|
|
|
describe 'when role is required' do
|
|
|
|
it 'after registering, it redirects to step 2 of the signup process, sets the name and role and then redirects to the original requested url' do
|
|
|
|
new_user = build_stubbed(:user)
|
|
|
|
visit new_user_registration_path
|
2020-01-17 04:08:24 -05:00
|
|
|
fill_in 'new_user_first_name', with: new_user.first_name
|
|
|
|
fill_in 'new_user_last_name', with: new_user.last_name
|
2019-10-18 17:06:37 -04:00
|
|
|
fill_in 'new_user_username', with: new_user.username
|
|
|
|
fill_in 'new_user_email', with: new_user.email
|
|
|
|
fill_in 'new_user_password', with: new_user.password
|
|
|
|
click_button 'Register'
|
|
|
|
visit new_project_path
|
|
|
|
|
|
|
|
expect(page).to have_current_path(users_sign_up_welcome_path)
|
|
|
|
|
|
|
|
select 'Software Developer', from: 'user_role'
|
2019-11-08 10:06:21 -05:00
|
|
|
choose 'user_setup_for_company_true'
|
2019-10-18 17:06:37 -04:00
|
|
|
click_button 'Get started!'
|
|
|
|
new_user = User.find_by_username(new_user.username)
|
|
|
|
|
|
|
|
expect(new_user.software_developer_role?).to be_truthy
|
2019-11-08 10:06:21 -05:00
|
|
|
expect(new_user.setup_for_company).to be_truthy
|
2019-10-18 17:06:37 -04:00
|
|
|
expect(page).to have_current_path(new_project_path)
|
2019-10-07 11:05:59 -04:00
|
|
|
end
|
|
|
|
end
|
2020-08-05 08:09:45 -04:00
|
|
|
|
|
|
|
context 'when terms_opt_in experimental is enabled' do
|
|
|
|
include TermsHelper
|
|
|
|
|
|
|
|
before do
|
|
|
|
enforce_terms
|
|
|
|
stub_experiment(signup_flow: true, terms_opt_in: true)
|
|
|
|
stub_experiment_for_user(signup_flow: true, terms_opt_in: true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'terms are checked by default' do
|
|
|
|
new_user = build_stubbed(:user)
|
|
|
|
visit new_user_registration_path
|
|
|
|
|
|
|
|
fill_in 'new_user_username', with: new_user.username
|
|
|
|
fill_in 'new_user_email', with: new_user.email
|
|
|
|
fill_in 'new_user_first_name', with: new_user.first_name
|
|
|
|
fill_in 'new_user_last_name', with: new_user.last_name
|
|
|
|
fill_in 'new_user_password', with: new_user.password
|
|
|
|
|
|
|
|
click_button 'Register'
|
|
|
|
|
|
|
|
expect(current_path).to eq users_sign_up_welcome_path
|
|
|
|
end
|
|
|
|
end
|
2019-10-07 11:05:59 -04:00
|
|
|
end
|