From b86f474bf51e20d2db4cf0895d0a8e0894e31c08 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 11 Dec 2019 12:08:10 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- spec/views/admin/sessions/new.html.haml_spec.rb | 35 +++++++++++++++++------- spec/views/layouts/application.html.haml_spec.rb | 1 + 2 files changed, 26 insertions(+), 10 deletions(-) (limited to 'spec/views') diff --git a/spec/views/admin/sessions/new.html.haml_spec.rb b/spec/views/admin/sessions/new.html.haml_spec.rb index 57255748988..b3208296c80 100644 --- a/spec/views/admin/sessions/new.html.haml_spec.rb +++ b/spec/views/admin/sessions/new.html.haml_spec.rb @@ -3,29 +3,44 @@ require 'spec_helper' describe 'admin/sessions/new.html.haml' do - context 'admin has password set' do - before do - allow(view).to receive(:password_authentication_enabled_for_web?).and_return(true) - end + let(:user) { create(:admin) } + + before do + allow(view).to receive(:current_user).and_return(user) + allow(view).to receive(:omniauth_enabled?).and_return(false) + end - it "shows enter password form" do + context 'internal admin user' do + it 'shows enter password form' do render expect(rendered).to have_css('#login-pane.active') expect(rendered).to have_selector('input[name="password"]') end + + it 'warns authentication not possible if password not set' do + allow(user).to receive(:require_password_creation_for_web?).and_return(true) + + render + + expect(rendered).not_to have_css('#login-pane') + expect(rendered).to have_content _('No authentication methods configured.') + end end - context 'admin has no password set' do + context 'omniauth authentication enabled' do before do - allow(view).to receive(:password_authentication_enabled_for_web?).and_return(false) + allow(view).to receive(:omniauth_enabled?).and_return(true) + allow(view).to receive(:button_based_providers_enabled?).and_return(true) end - it "warns authentication not possible" do + it 'shows omniauth form' do render - expect(rendered).not_to have_css('#login-pane') - expect(rendered).to have_content 'No authentication methods configured' + expect(rendered).to have_css('.omniauth-container') + expect(rendered).to have_content _('Sign in with') + + expect(rendered).not_to have_content _('No authentication methods configured.') end end end diff --git a/spec/views/layouts/application.html.haml_spec.rb b/spec/views/layouts/application.html.haml_spec.rb index bdd4a97a1f5..4270bbf1924 100644 --- a/spec/views/layouts/application.html.haml_spec.rb +++ b/spec/views/layouts/application.html.haml_spec.rb @@ -11,6 +11,7 @@ describe 'layouts/application' do allow(view).to receive(:session).and_return({}) allow(view).to receive(:user_signed_in?).and_return(true) allow(view).to receive(:current_user).and_return(user) + allow(view).to receive(:current_user_mode).and_return(Gitlab::Auth::CurrentUserMode.new(user)) end context 'body data elements for pageview context' do -- cgit v1.2.3