diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-19 15:57:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-19 15:57:54 +0300 |
commit | 419c53ec62de6e97a517abd5fdd4cbde3a942a34 (patch) | |
tree | 1f43a548b46bca8a5fb8fe0c31cef1883d49c5b6 /spec/helpers/auth_helper_spec.rb | |
parent | 1da20d9135b3ad9e75e65b028bffc921aaf8deb7 (diff) |
Add latest changes from gitlab-org/gitlab@16-5-stable-eev16.5.0-rc42
Diffstat (limited to 'spec/helpers/auth_helper_spec.rb')
-rw-r--r-- | spec/helpers/auth_helper_spec.rb | 96 |
1 files changed, 8 insertions, 88 deletions
diff --git a/spec/helpers/auth_helper_spec.rb b/spec/helpers/auth_helper_spec.rb index 4b0b44d1325..40798b4c038 100644 --- a/spec/helpers/auth_helper_spec.rb +++ b/spec/helpers/auth_helper_spec.rb @@ -35,12 +35,12 @@ RSpec.describe AuthHelper do describe "form_based_providers" do it 'includes LDAP providers' do allow(helper).to receive(:auth_providers) { [:twitter, :ldapmain] } - expect(helper.form_based_providers).to eq %i(ldapmain) + expect(helper.form_based_providers).to eq %i[ldapmain] end it 'includes crowd provider' do allow(helper).to receive(:auth_providers) { [:twitter, :crowd] } - expect(helper.form_based_providers).to eq %i(crowd) + expect(helper.form_based_providers).to eq %i[crowd] end end @@ -101,15 +101,15 @@ RSpec.describe AuthHelper do describe 'popular_enabled_button_based_providers' do it 'returns the intersection set of popular & enabled providers', :aggregate_failures do - allow(helper).to receive(:enabled_button_based_providers) { %w(twitter github google_oauth2) } + allow(helper).to receive(:enabled_button_based_providers) { %w[twitter github google_oauth2] } - expect(helper.popular_enabled_button_based_providers).to eq(%w(github google_oauth2)) + expect(helper.popular_enabled_button_based_providers).to eq(%w[github google_oauth2]) - allow(helper).to receive(:enabled_button_based_providers) { %w(google_oauth2 bitbucket) } + allow(helper).to receive(:enabled_button_based_providers) { %w[google_oauth2 bitbucket] } - expect(helper.popular_enabled_button_based_providers).to eq(%w(google_oauth2)) + expect(helper.popular_enabled_button_based_providers).to eq(%w[google_oauth2]) - allow(helper).to receive(:enabled_button_based_providers) { %w(bitbucket) } + allow(helper).to receive(:enabled_button_based_providers) { %w[bitbucket] } expect(helper.popular_enabled_button_based_providers).to be_empty end @@ -129,7 +129,7 @@ RSpec.describe AuthHelper do context 'all the button based providers are disabled via application_setting' do it 'returns false' do stub_application_setting( - disabled_oauth_sign_in_sources: %w(github twitter) + disabled_oauth_sign_in_sources: %w[github twitter] ) expect(helper.button_based_providers_enabled?).to be false @@ -277,86 +277,6 @@ RSpec.describe AuthHelper do end end - describe '#google_tag_manager_enabled?' do - let(:is_gitlab_com) { true } - let(:user) { nil } - - before do - allow(Gitlab).to receive(:com?).and_return(is_gitlab_com) - allow(helper).to receive(:current_user).and_return(user) - end - - subject(:google_tag_manager_enabled) { helper.google_tag_manager_enabled? } - - context 'when not on gitlab.com' do - let(:is_gitlab_com) { false } - - it { is_expected.to eq(false) } - end - - context 'regular and nonce versions' do - using RSpec::Parameterized::TableSyntax - - where(:gtm_nonce_enabled, :gtm_key) do - false | 'google_tag_manager_id' - true | 'google_tag_manager_nonce_id' - end - - with_them do - before do - stub_feature_flags(gtm_nonce: gtm_nonce_enabled) - stub_config(extra: { gtm_key => 'key' }) - end - - context 'on gitlab.com and a key set without a current user' do - it { is_expected.to be_truthy } - end - - context 'when no key is set' do - before do - stub_config(extra: {}) - end - - it { is_expected.to eq(false) } - end - end - end - end - - describe '#google_tag_manager_id' do - subject(:google_tag_manager_id) { helper.google_tag_manager_id } - - before do - stub_config(extra: { 'google_tag_manager_nonce_id': 'nonce', 'google_tag_manager_id': 'gtm' }) - end - - context 'when google tag manager is disabled' do - before do - allow(helper).to receive(:google_tag_manager_enabled?).and_return(false) - end - - it { is_expected.to be_falsey } - end - - context 'when google tag manager is enabled' do - before do - allow(helper).to receive(:google_tag_manager_enabled?).and_return(true) - end - - context 'when nonce feature flag is enabled' do - it { is_expected.to eq('nonce') } - end - - context 'when nonce feature flag is disabled' do - before do - stub_feature_flags(gtm_nonce: false) - end - - it { is_expected.to eq('gtm') } - end - end - end - describe '#auth_app_owner_text' do shared_examples 'generates text with the correct info' do it 'includes the name of the application owner' do |