summaryrefslogtreecommitdiff
path: root/spec/features/users/signup_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/features/users/signup_spec.rb')
-rw-r--r--spec/features/users/signup_spec.rb168
1 files changed, 125 insertions, 43 deletions
diff --git a/spec/features/users/signup_spec.rb b/spec/features/users/signup_spec.rb
index 0846ec8dfb4..562d6fcab1b 100644
--- a/spec/features/users/signup_spec.rb
+++ b/spec/features/users/signup_spec.rb
@@ -5,10 +5,6 @@ require 'spec_helper'
shared_examples 'Signup' do
include TermsHelper
- before do
- stub_feature_flags(invisible_captcha: false)
- end
-
let(:new_user) { build_stubbed(:user) }
describe 'username validation', :js do
@@ -129,35 +125,43 @@ shared_examples 'Signup' do
describe 'user\'s full name validation', :js do
before do
- visit new_user_registration_path
+ if Gitlab::Experimentation.enabled?(:signup_flow)
+ user = create(:user, role: nil)
+ sign_in(user)
+ visit users_sign_up_welcome_path
+ @user_name_field = 'user_name'
+ else
+ visit new_user_registration_path
+ @user_name_field = 'new_user_name'
+ end
end
it 'does not show an error border if the user\'s fullname length is not longer than 128 characters' do
- fill_in 'new_user_name', with: 'u' * 128
+ fill_in @user_name_field, with: 'u' * 128
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('#new_user_name', 'Ehsan 🦋')
+ simulate_input("##{@user_name_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 128 characters' do
- fill_in 'new_user_name', with: 'n' * 129
+ fill_in @user_name_field, with: 'n' * 129
expect(find('.name')).to have_css '.gl-field-error-outline'
end
it 'shows an error message if the user\'s fullname is longer than 128 characters' do
- fill_in 'new_user_name', with: 'n' * 129
+ fill_in @user_name_field, with: 'n' * 129
expect(page).to have_content("Name is too long (maximum is 128 characters).")
end
it 'shows an error message if the username contains emojis' do
- simulate_input('#new_user_name', 'Ehsan 🦋')
+ simulate_input("##{@user_name_field}", 'Ehsan 🦋')
expect(page).to have_content("Invalid input, please avoid emojis")
end
@@ -177,11 +181,11 @@ shared_examples 'Signup' do
it 'creates the user account and sends a confirmation email' do
visit new_user_registration_path
- fill_in 'new_user_name', with: new_user.name
fill_in 'new_user_username', with: new_user.username
fill_in 'new_user_email', with: new_user.email
- unless Feature.enabled?(:experimental_separate_sign_up_flow)
+ unless Gitlab::Experimentation.enabled?(:signup_flow)
+ fill_in 'new_user_name', with: new_user.name
fill_in 'new_user_email_confirmation', with: new_user.email
end
@@ -202,11 +206,11 @@ shared_examples 'Signup' do
it 'creates the user account and sends a confirmation email' do
visit new_user_registration_path
- fill_in 'new_user_name', with: new_user.name
fill_in 'new_user_username', with: new_user.username
fill_in 'new_user_email', with: new_user.email
- unless Feature.enabled?(:experimental_separate_sign_up_flow)
+ unless Gitlab::Experimentation.enabled?(:signup_flow)
+ fill_in 'new_user_name', with: new_user.name
fill_in 'new_user_email_confirmation', with: new_user.email
end
@@ -214,8 +218,12 @@ shared_examples 'Signup' do
expect { click_button 'Register' }.to change { User.count }.by(1)
- 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.")
+ 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.")
+ end
end
end
end
@@ -224,19 +232,23 @@ shared_examples 'Signup' do
it "creates the user successfully" do
visit new_user_registration_path
- fill_in 'new_user_name', with: new_user.name
fill_in 'new_user_username', with: new_user.username
fill_in 'new_user_email', with: new_user.email
- unless Feature.enabled?(:experimental_separate_sign_up_flow)
+ unless Gitlab::Experimentation.enabled?(:signup_flow)
+ fill_in 'new_user_name', with: new_user.name
fill_in 'new_user_email_confirmation', with: new_user.email.capitalize
end
fill_in 'new_user_password', with: new_user.password
click_button "Register"
- expect(current_path).to eq dashboard_projects_path
- expect(page).to have_content("Welcome! You have signed up successfully.")
+ 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
end
end
@@ -248,19 +260,23 @@ shared_examples 'Signup' do
it 'creates the user account and goes to dashboard' do
visit new_user_registration_path
- fill_in 'new_user_name', with: new_user.name
fill_in 'new_user_username', with: new_user.username
fill_in 'new_user_email', with: new_user.email
- unless Feature.enabled?(:experimental_separate_sign_up_flow)
+ unless Gitlab::Experimentation.enabled?(:signup_flow)
+ 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
click_button "Register"
- expect(current_path).to eq dashboard_projects_path
- expect(page).to have_content("Welcome! You have signed up successfully.")
+ 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
end
end
end
@@ -271,7 +287,10 @@ shared_examples 'Signup' do
visit new_user_registration_path
- fill_in 'new_user_name', with: new_user.name
+ unless Gitlab::Experimentation.enabled?(:signup_flow)
+ fill_in 'new_user_name', with: new_user.name
+ end
+
fill_in 'new_user_username', with: new_user.username
fill_in 'new_user_email', with: existing_user.email
fill_in 'new_user_password', with: new_user.password
@@ -279,14 +298,14 @@ shared_examples 'Signup' do
expect(current_path).to eq user_registration_path
- if Feature.enabled?(:experimental_separate_sign_up_flow)
+ if Gitlab::Experimentation.enabled?(:signup_flow)
expect(page).to have_content("error prohibited this user from being saved")
- expect(page).to have_content("Email has already been taken")
else
expect(page).to have_content("errors prohibited this user from being saved")
- expect(page).to have_content("Email has already been taken")
expect(page).to have_content("Email confirmation doesn't match")
end
+
+ expect(page).to have_content("Email has already been taken")
end
it 'does not redisplay the password' do
@@ -294,7 +313,10 @@ shared_examples 'Signup' do
visit new_user_registration_path
- fill_in 'new_user_name', with: new_user.name
+ unless Gitlab::Experimentation.enabled?(:signup_flow)
+ fill_in 'new_user_name', with: new_user.name
+ end
+
fill_in 'new_user_username', with: new_user.username
fill_in 'new_user_email', with: existing_user.email
fill_in 'new_user_password', with: new_user.password
@@ -313,11 +335,11 @@ shared_examples 'Signup' do
it 'requires the user to check the checkbox' do
visit new_user_registration_path
- fill_in 'new_user_name', with: new_user.name
fill_in 'new_user_username', with: new_user.username
fill_in 'new_user_email', with: new_user.email
- unless Feature.enabled?(:experimental_separate_sign_up_flow)
+ unless Gitlab::Experimentation.enabled?(:signup_flow)
+ fill_in 'new_user_name', with: new_user.name
fill_in 'new_user_email_confirmation', with: new_user.email
end
@@ -332,11 +354,11 @@ shared_examples 'Signup' do
it 'asks the user to accept terms before going to the dashboard' do
visit new_user_registration_path
- fill_in 'new_user_name', with: new_user.name
fill_in 'new_user_username', with: new_user.username
fill_in 'new_user_email', with: new_user.email
- unless Feature.enabled?(:experimental_separate_sign_up_flow)
+ unless Gitlab::Experimentation.enabled?(:signup_flow)
+ fill_in 'new_user_name', with: new_user.name
fill_in 'new_user_email_confirmation', with: new_user.email
end
@@ -345,24 +367,84 @@ shared_examples 'Signup' do
click_button "Register"
- expect(current_path).to eq dashboard_projects_path
+ 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
end
end
-end
-describe 'With original flow' do
- it_behaves_like 'Signup' do
+ context 'when reCAPTCHA and invisible captcha are enabled' do
before do
- stub_feature_flags(experimental_separate_sign_up_flow: false)
+ InvisibleCaptcha.timestamp_enabled = true
+ stub_application_setting(recaptcha_enabled: true)
+ allow_any_instance_of(RegistrationsController).to receive(:verify_recaptcha).and_return(false)
+ end
+
+ after do
+ InvisibleCaptcha.timestamp_enabled = false
+ end
+
+ it 'prevents from signing up' do
+ visit new_user_registration_path
+
+ fill_in 'new_user_username', with: new_user.username
+ fill_in 'new_user_email', with: new_user.email
+
+ unless Gitlab::Experimentation.enabled?(:signup_flow)
+ 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 }
+
+ if Gitlab::Experimentation.enabled?(:signup_flow)
+ expect(page).to have_content('That was a bit too quick! Please resubmit.')
+ else
+ expect(page).to have_content('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.')
+ end
end
end
end
-describe 'With experimental flow on GitLab.com' do
- it_behaves_like 'Signup' do
- before do
- expect(Gitlab).to receive(:com?).and_return(true).at_least(:once)
- stub_feature_flags(experimental_separate_sign_up_flow: true)
+describe 'With original flow' do
+ before do
+ stub_experiment(signup_flow: false)
+ end
+
+ it_behaves_like 'Signup'
+end
+
+describe 'With experimental flow' do
+ before do
+ stub_experiment(signup_flow: true)
+ end
+
+ it_behaves_like 'Signup'
+
+ 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
+ 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)
+
+ fill_in 'user_name', with: 'New name'
+ select 'Software Developer', from: 'user_role'
+ click_button 'Get started!'
+ new_user = User.find_by_username(new_user.username)
+
+ expect(new_user.name).to eq 'New name'
+ expect(new_user.software_developer_role?).to be_truthy
+ expect(page).to have_current_path(new_project_path)
end
end
end