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:
Diffstat (limited to 'spec/lib/gitlab/auth/o_auth/user_spec.rb')
-rw-r--r--spec/lib/gitlab/auth/o_auth/user_spec.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/lib/gitlab/auth/o_auth/user_spec.rb b/spec/lib/gitlab/auth/o_auth/user_spec.rb
index 6cb9085c3ad..5f5e7f211f8 100644
--- a/spec/lib/gitlab/auth/o_auth/user_spec.rb
+++ b/spec/lib/gitlab/auth/o_auth/user_spec.rb
@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe Gitlab::Auth::OAuth::User do
include LdapHelpers
+ include TermsHelper
let(:oauth_user) { described_class.new(auth_hash) }
let(:oauth_user_2) { described_class.new(auth_hash_2) }
@@ -144,6 +145,49 @@ RSpec.describe Gitlab::Auth::OAuth::User do
expect(gl_user).to be_password_automatically_set
end
+ context 'terms of service' do
+ context 'when terms are enforced' do
+ before do
+ enforce_terms
+ end
+
+ context 'when feature flag update_oauth_registration_flow is enabled' do
+ before do
+ stub_feature_flags(update_oauth_registration_flow: true)
+ end
+
+ it 'creates the user with accepted terms' do
+ oauth_user.save # rubocop:disable Rails/SaveBang
+
+ expect(gl_user).to be_persisted
+ expect(gl_user.terms_accepted?).to be(true)
+ end
+ end
+
+ context 'when feature flag update_oauth_registration_flow is disabled' do
+ before do
+ stub_feature_flags(update_oauth_registration_flow: false)
+ end
+
+ it 'creates the user without accepted terms' do
+ oauth_user.save # rubocop:disable Rails/SaveBang
+
+ expect(gl_user).to be_persisted
+ expect(gl_user.terms_accepted?).to be(false)
+ end
+ end
+ end
+
+ context 'when terms are not enforced' do
+ it 'creates the user without accepted terms' do
+ oauth_user.save # rubocop:disable Rails/SaveBang
+
+ expect(gl_user).to be_persisted
+ expect(gl_user.terms_accepted?).to be(false)
+ end
+ end
+ end
+
shared_examples 'to verify compliance with allow_single_sign_on' do
context 'provider is marked as external' do
it 'marks user as external' do