Commit 3bccf2fd authored by Michael Kozono's avatar Michael Kozono

Refactor with LDAP spec helpers

parent a27b4f74
require 'spec_helper' require 'spec_helper'
describe Gitlab::LDAP::User do describe Gitlab::LDAP::User do
include LdapHelpers
let(:ldap_user) { described_class.new(auth_hash) } let(:ldap_user) { described_class.new(auth_hash) }
let(:gl_user) { ldap_user.gl_user } let(:gl_user) { ldap_user.gl_user }
let(:info) do let(:info) do
...@@ -174,8 +176,7 @@ describe Gitlab::LDAP::User do ...@@ -174,8 +176,7 @@ describe Gitlab::LDAP::User do
describe 'blocking' do describe 'blocking' do
def configure_block(value) def configure_block(value)
allow_any_instance_of(Gitlab::LDAP::Config) stub_ldap_config(block_auto_created_users: value)
.to receive(:block_auto_created_users).and_return(value)
end end
context 'signup' do context 'signup' do
...@@ -268,7 +269,7 @@ describe Gitlab::LDAP::User do ...@@ -268,7 +269,7 @@ describe Gitlab::LDAP::User do
describe '#in_any_external_group?' do describe '#in_any_external_group?' do
context 'when there is an external group' do context 'when there is an external group' do
before do before do
expect_any_instance_of(Gitlab::LDAP::Config).to receive(:external_groups).and_return(['foo']) stub_ldap_config(external_groups: ['foo'])
end end
context 'when the user is in an external group' do context 'when the user is in an external group' do
...@@ -294,7 +295,7 @@ describe Gitlab::LDAP::User do ...@@ -294,7 +295,7 @@ describe Gitlab::LDAP::User do
context 'when are no external groups' do context 'when are no external groups' do
before do before do
expect_any_instance_of(Gitlab::LDAP::Config).to receive(:external_groups).and_return([]) stub_ldap_config(external_groups: [])
end end
it 'returns false' do it 'returns false' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment