diff options
Diffstat (limited to 'spec/views/devise/sessions/new.html.haml_spec.rb')
-rw-r--r-- | spec/views/devise/sessions/new.html.haml_spec.rb | 94 |
1 files changed, 51 insertions, 43 deletions
diff --git a/spec/views/devise/sessions/new.html.haml_spec.rb b/spec/views/devise/sessions/new.html.haml_spec.rb index b3cd1493149..c8e9aa15287 100644 --- a/spec/views/devise/sessions/new.html.haml_spec.rb +++ b/spec/views/devise/sessions/new.html.haml_spec.rb @@ -9,6 +9,7 @@ RSpec.describe 'devise/sessions/new' do before do stub_devise disable_captcha + stub_feature_flags(restyle_login_page: false) allow(Gitlab).to receive(:com?).and_return(true) end @@ -29,67 +30,74 @@ RSpec.describe 'devise/sessions/new' do end end - describe 'ldap' do - include LdapHelpers - - let(:server) { { provider_name: 'ldapmain', label: 'LDAP' }.with_indifferent_access } - + flag_values = [true, false] + flag_values.each do |val| before do - enable_ldap - stub_devise - disable_captcha - disable_sign_up - disable_other_signin_methods - - allow(view).to receive(:experiment_enabled?).and_return(false) + stub_feature_flags(restyle_login_page: val) end - it 'is shown when enabled' do - render + describe 'ldap' do + include LdapHelpers - expect(rendered).to have_selector('.new-session-tabs') - expect(rendered).to have_selector('[data-qa-selector="ldap_tab"]') # rubocop:disable QA/SelectorUsage - expect(rendered).to have_field('LDAP Username') - end + let(:server) { { provider_name: 'ldapmain', label: 'LDAP' }.with_indifferent_access } - it 'is not shown when LDAP sign in is disabled' do - disable_ldap_sign_in + before do + enable_ldap + stub_devise + disable_captcha + disable_sign_up + disable_other_signin_methods - render + allow(view).to receive(:experiment_enabled?).and_return(false) + end - expect(rendered).to have_content('No authentication methods configured') - expect(rendered).not_to have_selector('[data-qa-selector="ldap_tab"]') # rubocop:disable QA/SelectorUsage - expect(rendered).not_to have_field('LDAP Username') - end - end + it 'is shown when enabled' do + render - describe 'Google Tag Manager' do - let!(:gtm_id) { 'GTM-WWKMTWS'} + expect(rendered).to have_selector('.new-session-tabs') + expect(rendered).to have_selector('[data-qa-selector="ldap_tab"]') # rubocop:disable QA/SelectorUsage + expect(rendered).to have_field('LDAP Username') + end - subject { rendered } + it 'is not shown when LDAP sign in is disabled' do + disable_ldap_sign_in - before do - stub_devise - disable_captcha - stub_config(extra: { google_tag_manager_id: gtm_id, google_tag_manager_nonce_id: gtm_id }) + render + + expect(rendered).to have_content('No authentication methods configured') + expect(rendered).not_to have_selector('[data-qa-selector="ldap_tab"]') # rubocop:disable QA/SelectorUsage + expect(rendered).not_to have_field('LDAP Username') + end end - describe 'when Google Tag Manager is enabled' do + describe 'Google Tag Manager' do + let!(:gtm_id) { 'GTM-WWKMTWS' } + + subject { rendered } + before do - enable_gtm - render + stub_devise + disable_captcha + stub_config(extra: { google_tag_manager_id: gtm_id, google_tag_manager_nonce_id: gtm_id }) end - it { is_expected.to match /www.googletagmanager.com/ } - end + describe 'when Google Tag Manager is enabled' do + before do + enable_gtm + render + end - describe 'when Google Tag Manager is disabled' do - before do - disable_gtm - render + it { is_expected.to match /www.googletagmanager.com/ } end - it { is_expected.not_to match /www.googletagmanager.com/ } + describe 'when Google Tag Manager is disabled' do + before do + disable_gtm + render + end + + it { is_expected.not_to match /www.googletagmanager.com/ } + end end end |