debian-mirror-gitlab/spec/views/admin/sessions/new.html.haml_spec.rb

47 lines
1.3 KiB
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
require 'spec_helper'
describe 'admin/sessions/new.html.haml' do
2020-01-01 13:55:28 +05:30
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
2019-12-21 20:55:43 +05:30
2020-01-01 13:55:28 +05:30
context 'internal admin user' do
it 'shows enter password form' do
2019-12-21 20:55:43 +05:30
render
expect(rendered).to have_css('#login-pane.active')
2020-04-08 14:13:33 +05:30
expect(rendered).to have_selector('input[name="user[password]"]')
2019-12-21 20:55:43 +05:30
end
2020-01-01 13:55:28 +05:30
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
2019-12-21 20:55:43 +05:30
end
2020-01-01 13:55:28 +05:30
context 'omniauth authentication enabled' do
2019-12-21 20:55:43 +05:30
before do
2020-01-01 13:55:28 +05:30
allow(view).to receive(:omniauth_enabled?).and_return(true)
allow(view).to receive(:button_based_providers_enabled?).and_return(true)
2019-12-21 20:55:43 +05:30
end
2020-01-01 13:55:28 +05:30
it 'shows omniauth form' do
2019-12-21 20:55:43 +05:30
render
2020-01-01 13:55:28 +05:30
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.')
2019-12-21 20:55:43 +05:30
end
end
end