2019-04-15 06:17:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-04-21 14:55:54 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-03 14:08:28 -04:00
|
|
|
RSpec.describe RegistrationsController do
|
2018-06-08 07:20:44 -04:00
|
|
|
include TermsHelper
|
|
|
|
|
2019-08-09 11:40:54 -04:00
|
|
|
before do
|
|
|
|
stub_feature_flags(invisible_captcha: false)
|
|
|
|
end
|
|
|
|
|
2019-10-23 11:06:29 -04:00
|
|
|
describe '#new' do
|
|
|
|
subject { get :new }
|
|
|
|
|
|
|
|
context 'with the experimental signup flow enabled and the user is part of the experimental group' do
|
|
|
|
before do
|
|
|
|
stub_experiment(signup_flow: true)
|
|
|
|
stub_experiment_for_user(signup_flow: true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'tracks the event with the right parameters' do
|
|
|
|
expect(Gitlab::Tracking).to receive(:event).with(
|
|
|
|
'Growth::Acquisition::Experiment::SignUpFlow',
|
|
|
|
'start',
|
|
|
|
label: anything,
|
|
|
|
property: 'experimental_group'
|
|
|
|
)
|
|
|
|
subject
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders new template and sets the resource variable' do
|
|
|
|
expect(subject).to render_template(:new)
|
2020-01-27 07:08:35 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
2019-10-23 11:06:29 -04:00
|
|
|
expect(assigns(:resource)).to be_a(User)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with the experimental signup flow enabled and the user is part of the control group' do
|
|
|
|
before do
|
|
|
|
stub_experiment(signup_flow: true)
|
|
|
|
stub_experiment_for_user(signup_flow: false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not track the event' do
|
|
|
|
expect(Gitlab::Tracking).not_to receive(:event)
|
|
|
|
subject
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders new template and sets the resource variable' do
|
|
|
|
subject
|
2020-01-27 07:08:35 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:found)
|
2019-10-23 11:06:29 -04:00
|
|
|
expect(response).to redirect_to(new_user_session_path(anchor: 'register-pane'))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-04-21 14:55:54 -04:00
|
|
|
describe '#create' do
|
2019-06-25 18:32:54 -04:00
|
|
|
let(:base_user_params) { { name: 'new_user', username: 'new_username', email: 'new@user.com', password: 'Any_password' } }
|
|
|
|
let(:user_params) { { user: base_user_params } }
|
2017-01-03 02:08:21 -05:00
|
|
|
|
|
|
|
context 'email confirmation' do
|
2017-08-10 18:31:42 -04:00
|
|
|
around do |example|
|
2017-01-03 02:08:21 -05:00
|
|
|
perform_enqueued_jobs do
|
|
|
|
example.run
|
|
|
|
end
|
2016-04-21 14:55:54 -04:00
|
|
|
end
|
|
|
|
|
2017-01-03 02:08:21 -05:00
|
|
|
context 'when send_user_confirmation_email is false' do
|
|
|
|
it 'signs the user in' do
|
2019-03-06 07:12:04 -05:00
|
|
|
stub_application_setting(send_user_confirmation_email: false)
|
2017-01-03 02:08:21 -05:00
|
|
|
|
2018-12-17 17:52:17 -05:00
|
|
|
expect { post(:create, params: user_params) }.not_to change { ActionMailer::Base.deliveries.size }
|
2017-01-03 02:08:21 -05:00
|
|
|
expect(subject.current_user).not_to be_nil
|
|
|
|
end
|
|
|
|
end
|
2016-04-21 14:55:54 -04:00
|
|
|
|
2017-01-03 02:08:21 -05:00
|
|
|
context 'when send_user_confirmation_email is true' do
|
2019-07-31 10:49:52 -04:00
|
|
|
before do
|
2019-03-06 07:12:04 -05:00
|
|
|
stub_application_setting(send_user_confirmation_email: true)
|
2019-07-31 10:49:52 -04:00
|
|
|
end
|
|
|
|
|
2020-03-11 20:09:34 -04:00
|
|
|
context 'when soft email confirmation is not enabled' do
|
2020-02-11 07:08:52 -05:00
|
|
|
before do
|
2020-03-11 20:09:34 -04:00
|
|
|
stub_feature_flags(soft_email_confirmation: false)
|
|
|
|
allow(User).to receive(:allow_unconfirmed_access_for).and_return 0
|
2020-02-11 07:08:52 -05:00
|
|
|
end
|
2019-07-31 10:49:52 -04:00
|
|
|
|
2020-03-11 20:09:34 -04:00
|
|
|
it 'does not authenticate the user and sends a confirmation email' do
|
2020-02-11 07:08:52 -05:00
|
|
|
post(:create, params: user_params)
|
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries.last.to.first).to eq(user_params[:user][:email])
|
2020-03-11 20:09:34 -04:00
|
|
|
expect(subject.current_user).to be_nil
|
2020-02-11 07:08:52 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-03-11 20:09:34 -04:00
|
|
|
context 'when soft email confirmation is enabled' do
|
2020-02-11 07:08:52 -05:00
|
|
|
before do
|
2020-03-11 20:09:34 -04:00
|
|
|
stub_feature_flags(soft_email_confirmation: true)
|
|
|
|
allow(User).to receive(:allow_unconfirmed_access_for).and_return 2.days
|
2020-02-11 07:08:52 -05:00
|
|
|
end
|
|
|
|
|
2020-03-11 20:09:34 -04:00
|
|
|
it 'authenticates the user and sends a confirmation email' do
|
2020-02-11 07:08:52 -05:00
|
|
|
post(:create, params: user_params)
|
|
|
|
|
|
|
|
expect(ActionMailer::Base.deliveries.last.to.first).to eq(user_params[:user][:email])
|
2020-03-11 20:09:34 -04:00
|
|
|
expect(response).to redirect_to(dashboard_projects_path)
|
2020-02-11 07:08:52 -05:00
|
|
|
end
|
2017-01-03 02:08:21 -05:00
|
|
|
end
|
2017-03-27 05:37:24 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when signup_enabled? is false' do
|
|
|
|
it 'redirects to sign_in' do
|
2019-03-06 07:12:04 -05:00
|
|
|
stub_application_setting(signup_enabled: false)
|
2017-03-27 05:37:24 -04:00
|
|
|
|
2018-12-17 17:52:17 -05:00
|
|
|
expect { post(:create, params: user_params) }.not_to change(User, :count)
|
2017-03-27 05:37:24 -04:00
|
|
|
expect(response).to redirect_to(new_user_session_path)
|
|
|
|
end
|
2016-04-21 14:55:54 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-01-03 02:08:21 -05:00
|
|
|
context 'when reCAPTCHA is enabled' do
|
|
|
|
before do
|
|
|
|
stub_application_setting(recaptcha_enabled: true)
|
|
|
|
end
|
|
|
|
|
2019-09-05 12:38:19 -04:00
|
|
|
after do
|
|
|
|
# Avoid test ordering issue and ensure `verify_recaptcha` returns true
|
|
|
|
unless Recaptcha.configuration.skip_verify_env.include?('test')
|
|
|
|
Recaptcha.configuration.skip_verify_env << 'test'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-01-03 02:08:21 -05:00
|
|
|
it 'displays an error when the reCAPTCHA is not solved' do
|
2019-09-06 13:54:58 -04:00
|
|
|
allow_any_instance_of(described_class).to receive(:verify_recaptcha).and_return(false)
|
2016-04-21 14:55:54 -04:00
|
|
|
|
2018-12-17 17:52:17 -05:00
|
|
|
post(:create, params: user_params)
|
2017-01-03 02:08:21 -05:00
|
|
|
|
|
|
|
expect(response).to render_template(:new)
|
2019-12-12 07:07:33 -05:00
|
|
|
expect(flash[:alert]).to eq(_('There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.'))
|
2017-01-03 02:08:21 -05:00
|
|
|
end
|
|
|
|
|
2020-04-21 14:09:31 -04:00
|
|
|
it 'redirects to the dashboard when the reCAPTCHA is solved' do
|
2018-12-17 17:52:17 -05:00
|
|
|
post(:create, params: user_params)
|
2017-01-03 02:08:21 -05:00
|
|
|
|
2019-12-12 07:07:33 -05:00
|
|
|
expect(flash[:notice]).to eq(I18n.t('devise.registrations.signed_up'))
|
2016-04-21 14:55:54 -04:00
|
|
|
end
|
|
|
|
end
|
2018-06-08 07:20:44 -04:00
|
|
|
|
2019-08-09 11:40:54 -04:00
|
|
|
context 'when invisible captcha is enabled' do
|
|
|
|
before do
|
|
|
|
stub_feature_flags(invisible_captcha: true)
|
2019-10-18 17:06:37 -04:00
|
|
|
InvisibleCaptcha.timestamp_enabled = true
|
2019-08-09 11:40:54 -04:00
|
|
|
InvisibleCaptcha.timestamp_threshold = treshold
|
|
|
|
end
|
|
|
|
|
2019-10-18 17:06:37 -04:00
|
|
|
after do
|
|
|
|
InvisibleCaptcha.timestamp_enabled = false
|
|
|
|
end
|
|
|
|
|
2019-08-09 11:40:54 -04:00
|
|
|
let(:treshold) { 4 }
|
|
|
|
let(:session_params) { { invisible_captcha_timestamp: form_rendered_time.iso8601 } }
|
|
|
|
let(:form_rendered_time) { Time.current }
|
|
|
|
let(:submit_time) { form_rendered_time + treshold }
|
2019-08-14 08:05:24 -04:00
|
|
|
let(:auth_log_attributes) do
|
|
|
|
{
|
|
|
|
message: auth_log_message,
|
|
|
|
env: :invisible_captcha_signup_bot_detected,
|
2019-08-20 14:12:28 -04:00
|
|
|
remote_ip: '0.0.0.0',
|
2019-08-14 08:05:24 -04:00
|
|
|
request_method: 'POST',
|
2019-08-20 14:12:28 -04:00
|
|
|
path: '/users'
|
2019-08-14 08:05:24 -04:00
|
|
|
}
|
|
|
|
end
|
2019-08-09 11:40:54 -04:00
|
|
|
|
|
|
|
describe 'the honeypot has not been filled and the signup form has not been submitted too quickly' do
|
|
|
|
it 'creates an account' do
|
|
|
|
travel_to(submit_time) do
|
|
|
|
expect { post(:create, params: user_params, session: session_params) }.to change(User, :count).by(1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-08-14 08:05:24 -04:00
|
|
|
describe 'honeypot spam detection' do
|
2019-08-09 11:40:54 -04:00
|
|
|
let(:user_params) { super().merge(firstname: 'Roy', lastname: 'Batty') }
|
2019-08-14 08:05:24 -04:00
|
|
|
let(:auth_log_message) { 'Invisible_Captcha_Honeypot_Request' }
|
2019-08-09 11:40:54 -04:00
|
|
|
|
2019-08-14 08:05:24 -04:00
|
|
|
it 'logs the request, refuses to create an account and renders an empty body' do
|
2019-08-09 11:40:54 -04:00
|
|
|
travel_to(submit_time) do
|
2019-08-14 08:05:24 -04:00
|
|
|
expect(Gitlab::Metrics).to receive(:counter)
|
|
|
|
.with(:bot_blocked_by_invisible_captcha_honeypot, 'Counter of blocked sign up attempts with filled honeypot')
|
|
|
|
.and_call_original
|
|
|
|
expect(Gitlab::AuthLogger).to receive(:error).with(auth_log_attributes).once
|
2019-08-09 11:40:54 -04:00
|
|
|
expect { post(:create, params: user_params, session: session_params) }.not_to change(User, :count)
|
2020-01-27 07:08:35 -05:00
|
|
|
expect(response).to have_gitlab_http_status(:ok)
|
2019-08-09 11:40:54 -04:00
|
|
|
expect(response.body).to be_empty
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-08-14 08:05:24 -04:00
|
|
|
describe 'timestamp spam detection' do
|
|
|
|
let(:auth_log_message) { 'Invisible_Captcha_Timestamp_Request' }
|
2019-08-09 11:40:54 -04:00
|
|
|
|
2019-08-14 08:05:24 -04:00
|
|
|
context 'the sign up form has been submitted without the invisible_captcha_timestamp parameter' do
|
|
|
|
let(:session_params) { nil }
|
|
|
|
|
|
|
|
it 'logs the request, refuses to create an account and displays a flash alert' do
|
|
|
|
travel_to(submit_time) do
|
|
|
|
expect(Gitlab::Metrics).to receive(:counter)
|
|
|
|
.with(:bot_blocked_by_invisible_captcha_timestamp, 'Counter of blocked sign up attempts with invalid timestamp')
|
|
|
|
.and_call_original
|
|
|
|
expect(Gitlab::AuthLogger).to receive(:error).with(auth_log_attributes).once
|
|
|
|
expect { post(:create, params: user_params, session: session_params) }.not_to change(User, :count)
|
|
|
|
expect(response).to redirect_to(new_user_session_path)
|
2019-12-12 07:07:33 -05:00
|
|
|
expect(flash[:alert]).to eq(I18n.t('invisible_captcha.timestamp_error_message'))
|
2019-08-14 08:05:24 -04:00
|
|
|
end
|
2019-08-09 11:40:54 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-08-14 08:05:24 -04:00
|
|
|
context 'the sign up form has been submitted too quickly' do
|
|
|
|
let(:submit_time) { form_rendered_time }
|
|
|
|
|
|
|
|
it 'logs the request, refuses to create an account and displays a flash alert' do
|
|
|
|
travel_to(submit_time) do
|
|
|
|
expect(Gitlab::Metrics).to receive(:counter)
|
|
|
|
.with(:bot_blocked_by_invisible_captcha_timestamp, 'Counter of blocked sign up attempts with invalid timestamp')
|
|
|
|
.and_call_original
|
|
|
|
expect(Gitlab::AuthLogger).to receive(:error).with(auth_log_attributes).once
|
|
|
|
expect { post(:create, params: user_params, session: session_params) }.not_to change(User, :count)
|
|
|
|
expect(response).to redirect_to(new_user_session_path)
|
2019-12-12 07:07:33 -05:00
|
|
|
expect(flash[:alert]).to eq(I18n.t('invisible_captcha.timestamp_error_message'))
|
2019-08-14 08:05:24 -04:00
|
|
|
end
|
2019-08-09 11:40:54 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-06-08 07:20:44 -04:00
|
|
|
context 'when terms are enforced' do
|
|
|
|
before do
|
|
|
|
enforce_terms
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'redirects back with a notice when the checkbox was not checked' do
|
2018-12-17 17:52:17 -05:00
|
|
|
post :create, params: user_params
|
2018-06-08 07:20:44 -04:00
|
|
|
|
2019-12-12 07:07:33 -05:00
|
|
|
expect(flash[:alert]).to eq(_('You must accept our Terms of Service and privacy policy in order to register an account'))
|
2018-06-08 07:20:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates the user with agreement when terms are accepted' do
|
2018-12-17 17:52:17 -05:00
|
|
|
post :create, params: user_params.merge(terms_opt_in: '1')
|
2018-06-08 07:20:44 -04:00
|
|
|
|
|
|
|
expect(subject.current_user).to be_present
|
|
|
|
expect(subject.current_user.terms_accepted?).to be(true)
|
|
|
|
end
|
|
|
|
end
|
2019-06-25 18:32:54 -04:00
|
|
|
|
2019-10-23 11:06:29 -04:00
|
|
|
describe 'tracking data' do
|
|
|
|
context 'with the experimental signup flow enabled and the user is part of the control group' do
|
|
|
|
before do
|
|
|
|
stub_experiment(signup_flow: true)
|
|
|
|
stub_experiment_for_user(signup_flow: false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'tracks the event with the right parameters' do
|
|
|
|
expect(Gitlab::Tracking).to receive(:event).with(
|
|
|
|
'Growth::Acquisition::Experiment::SignUpFlow',
|
|
|
|
'end',
|
|
|
|
label: anything,
|
|
|
|
property: 'control_group'
|
|
|
|
)
|
|
|
|
post :create, params: user_params
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with the experimental signup flow enabled and the user is part of the experimental group' do
|
|
|
|
before do
|
|
|
|
stub_experiment(signup_flow: true)
|
|
|
|
stub_experiment_for_user(signup_flow: true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not track the event' do
|
|
|
|
expect(Gitlab::Tracking).not_to receive(:event)
|
|
|
|
post :create, params: user_params
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-06-25 18:32:54 -04:00
|
|
|
it "logs a 'User Created' message" do
|
|
|
|
expect(Gitlab::AppLogger).to receive(:info).with(/\AUser Created: username=new_username email=new@user.com.+\z/).and_call_original
|
|
|
|
|
|
|
|
post(:create, params: user_params)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'handles when params are new_user' do
|
|
|
|
post(:create, params: { new_user: base_user_params })
|
|
|
|
|
|
|
|
expect(subject.current_user).not_to be_nil
|
|
|
|
end
|
2020-01-17 04:08:24 -05:00
|
|
|
|
|
|
|
context 'with the experimental signup flow enabled and the user is part of the experimental group' do
|
|
|
|
before do
|
|
|
|
stub_experiment(signup_flow: true)
|
|
|
|
stub_experiment_for_user(signup_flow: true)
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:base_user_params) { { first_name: 'First', last_name: 'Last', username: 'new_username', email: 'new@user.com', password: 'Any_password' } }
|
|
|
|
|
|
|
|
it 'sets name from first and last name' do
|
|
|
|
post :create, params: { new_user: base_user_params }
|
|
|
|
|
|
|
|
expect(User.last.first_name).to eq(base_user_params[:first_name])
|
|
|
|
expect(User.last.last_name).to eq(base_user_params[:last_name])
|
|
|
|
expect(User.last.name).to eq("#{base_user_params[:first_name]} #{base_user_params[:last_name]}")
|
|
|
|
end
|
|
|
|
end
|
2016-04-21 14:55:54 -04:00
|
|
|
end
|
2017-04-01 00:29:51 -04:00
|
|
|
|
|
|
|
describe '#destroy' do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
2017-10-06 16:40:41 -04:00
|
|
|
def expect_failure(message)
|
|
|
|
expect(flash[:alert]).to eq(message)
|
2020-03-31 17:08:05 -04:00
|
|
|
expect(response).to have_gitlab_http_status(:see_other)
|
2017-10-06 16:40:41 -04:00
|
|
|
expect(response).to redirect_to profile_account_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def expect_password_failure
|
2019-12-12 07:07:33 -05:00
|
|
|
expect_failure(s_('Profiles|Invalid password'))
|
2017-10-06 16:40:41 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def expect_username_failure
|
2019-12-12 07:07:33 -05:00
|
|
|
expect_failure(s_('Profiles|Invalid username'))
|
2017-10-06 16:40:41 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def expect_success
|
2019-12-12 07:07:33 -05:00
|
|
|
expect(flash[:notice]).to eq s_('Profiles|Account scheduled for removal.')
|
2020-03-31 17:08:05 -04:00
|
|
|
expect(response).to have_gitlab_http_status(:see_other)
|
2017-10-06 16:40:41 -04:00
|
|
|
expect(response).to redirect_to new_user_session_path
|
|
|
|
end
|
2017-04-01 00:29:51 -04:00
|
|
|
|
2017-10-06 16:40:41 -04:00
|
|
|
context 'user requires password confirmation' do
|
|
|
|
it 'fails if password confirmation is not provided' do
|
|
|
|
post :destroy
|
2017-04-01 00:29:51 -04:00
|
|
|
|
2017-10-06 16:40:41 -04:00
|
|
|
expect_password_failure
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'fails if password confirmation is wrong' do
|
2018-12-17 17:52:17 -05:00
|
|
|
post :destroy, params: { password: 'wrong password' }
|
2017-10-06 16:40:41 -04:00
|
|
|
|
|
|
|
expect_password_failure
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'succeeds if password is confirmed' do
|
2018-12-17 17:52:17 -05:00
|
|
|
post :destroy, params: { password: '12345678' }
|
2017-10-06 16:40:41 -04:00
|
|
|
|
|
|
|
expect_success
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'user does not require password confirmation' do
|
|
|
|
before do
|
2017-11-23 08:16:14 -05:00
|
|
|
stub_application_setting(password_authentication_enabled_for_web: false)
|
|
|
|
stub_application_setting(password_authentication_enabled_for_git: false)
|
2017-10-06 16:40:41 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'fails if username confirmation is not provided' do
|
|
|
|
post :destroy
|
|
|
|
|
|
|
|
expect_username_failure
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'fails if username confirmation is wrong' do
|
2018-12-17 17:52:17 -05:00
|
|
|
post :destroy, params: { username: 'wrong username' }
|
2017-10-06 16:40:41 -04:00
|
|
|
|
|
|
|
expect_username_failure
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'succeeds if username is confirmed' do
|
2018-12-17 17:52:17 -05:00
|
|
|
post :destroy, params: { username: user.username }
|
2017-10-06 16:40:41 -04:00
|
|
|
|
|
|
|
expect_success
|
|
|
|
end
|
2017-04-01 00:29:51 -04:00
|
|
|
end
|
|
|
|
end
|
2019-10-23 11:06:29 -04:00
|
|
|
|
2019-11-08 10:06:21 -05:00
|
|
|
describe '#update_registration' do
|
2019-10-23 11:06:29 -04:00
|
|
|
before do
|
|
|
|
stub_experiment(signup_flow: true)
|
|
|
|
stub_experiment_for_user(signup_flow: true)
|
|
|
|
sign_in(create(:user))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'tracks the event with the right parameters' do
|
|
|
|
expect(Gitlab::Tracking).to receive(:event).with(
|
|
|
|
'Growth::Acquisition::Experiment::SignUpFlow',
|
|
|
|
'end',
|
|
|
|
label: anything,
|
|
|
|
property: 'experimental_group'
|
|
|
|
)
|
2020-01-17 04:08:24 -05:00
|
|
|
patch :update_registration, params: { user: { role: 'software_developer', setup_for_company: 'false' } }
|
2019-10-23 11:06:29 -04:00
|
|
|
end
|
|
|
|
end
|
2020-01-31 07:08:33 -05:00
|
|
|
|
|
|
|
describe '#welcome' do
|
|
|
|
subject { get :welcome }
|
|
|
|
|
|
|
|
context 'signup_flow experiment enabled' do
|
|
|
|
before do
|
|
|
|
stub_experiment_for_user(signup_flow: true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders the devise_experimental_separate_sign_up_flow layout' do
|
2020-05-08 17:09:47 -04:00
|
|
|
sign_in(create(:user))
|
|
|
|
|
2020-01-31 07:08:33 -05:00
|
|
|
expected_layout = Gitlab.ee? ? :checkout : :devise_experimental_separate_sign_up_flow
|
|
|
|
|
|
|
|
expect(subject).to render_template(expected_layout)
|
|
|
|
end
|
2020-05-08 17:09:47 -04:00
|
|
|
|
|
|
|
context '2FA is required from group' do
|
|
|
|
before do
|
|
|
|
user = create(:user, require_two_factor_authentication_from_group: true)
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not perform a redirect' do
|
|
|
|
expect(subject).not_to redirect_to(profile_two_factor_auth_path)
|
|
|
|
end
|
|
|
|
end
|
2020-01-31 07:08:33 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'signup_flow experiment disabled' do
|
|
|
|
before do
|
2020-05-08 17:09:47 -04:00
|
|
|
sign_in(create(:user))
|
2020-01-31 07:08:33 -05:00
|
|
|
stub_experiment_for_user(signup_flow: false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'renders the devise layout' do
|
|
|
|
expected_layout = Gitlab.ee? ? :checkout : :devise
|
|
|
|
|
|
|
|
expect(subject).to render_template(expected_layout)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-04-21 14:55:54 -04:00
|
|
|
end
|