Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-11-19 11:27:35 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-11-19 11:27:35 +0300
commit7e9c479f7de77702622631cff2628a9c8dcbc627 (patch)
treec8f718a08e110ad7e1894510980d2155a6549197 /spec/controllers/registrations
parente852b0ae16db4052c1c567d9efa4facc81146e88 (diff)
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/controllers/registrations')
-rw-r--r--spec/controllers/registrations/welcome_controller_spec.rb79
1 files changed, 79 insertions, 0 deletions
diff --git a/spec/controllers/registrations/welcome_controller_spec.rb b/spec/controllers/registrations/welcome_controller_spec.rb
new file mode 100644
index 00000000000..d32c936b8c9
--- /dev/null
+++ b/spec/controllers/registrations/welcome_controller_spec.rb
@@ -0,0 +1,79 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Registrations::WelcomeController do
+ let(:user) { create(:user) }
+
+ describe '#welcome' do
+ subject(:show) { get :show }
+
+ context 'without a signed in user' do
+ it { is_expected.to redirect_to new_user_registration_path }
+ end
+
+ context 'when role or setup_for_company is not set' do
+ before do
+ sign_in(user)
+ end
+
+ it { is_expected.to render_template(:show) }
+ end
+
+ context 'when role is required and setup_for_company is not set' do
+ before do
+ user.set_role_required!
+ sign_in(user)
+ end
+
+ it { is_expected.to render_template(:show) }
+ end
+
+ context 'when role and setup_for_company is set' do
+ before do
+ user.update!(setup_for_company: false)
+ sign_in(user)
+ end
+
+ it { is_expected.to redirect_to(dashboard_projects_path)}
+ end
+
+ context 'when role is set and setup_for_company is not set' do
+ before do
+ user.update!(role: :software_developer)
+ sign_in(user)
+ end
+
+ it { is_expected.to render_template(:show) }
+ end
+
+ 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
+ end
+
+ describe '#update' do
+ subject(:update) do
+ patch :update, params: { user: { role: 'software_developer', setup_for_company: 'false' } }
+ end
+
+ context 'without a signed in user' do
+ it { is_expected.to redirect_to new_user_registration_path }
+ end
+
+ context 'with a signed in user' do
+ before do
+ sign_in(user)
+ end
+
+ it { is_expected.to redirect_to(dashboard_projects_path)}
+ end
+ end
+end