debian-mirror-gitlab/spec/controllers/passwords_controller_spec.rb

34 lines
1 KiB
Ruby
Raw Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
2017-09-10 17:25:29 +05:30
require 'spec_helper'
describe PasswordsController do
2018-03-17 18:26:18 +05:30
describe '#check_password_authentication_available' do
2017-09-10 17:25:29 +05:30
before do
@request.env["devise.mapping"] = Devise.mappings[:user]
end
2018-03-17 18:26:18 +05:30
context 'when password authentication is disabled for the web interface and Git' do
it 'prevents a password reset' do
stub_application_setting(password_authentication_enabled_for_web: false)
stub_application_setting(password_authentication_enabled_for_git: false)
2017-09-10 17:25:29 +05:30
post :create
2018-03-17 18:26:18 +05:30
expect(response).to have_gitlab_http_status(302)
2020-01-01 13:55:28 +05:30
expect(flash[:alert]).to eq _('Password authentication is unavailable.')
2017-09-10 17:25:29 +05:30
end
end
context 'when reset email belongs to an ldap user' do
let(:user) { create(:omniauth_user, provider: 'ldapmain', email: 'ldapuser@gitlab.com') }
it 'prevents a password reset' do
2019-02-15 15:39:39 +05:30
post :create, params: { user: { email: user.email } }
2017-09-10 17:25:29 +05:30
2020-01-01 13:55:28 +05:30
expect(flash[:alert]).to eq _('Password authentication is unavailable.')
2017-09-10 17:25:29 +05:30
end
end
end
end