gitlab-org--gitlab-foss/spec/lib/gitlab/ldap/access_spec.rb

33 lines
844 B
Ruby
Raw Normal View History

2014-05-14 16:14:06 +00:00
require 'spec_helper'
describe Gitlab::LDAP::Access do
let(:access) { Gitlab::LDAP::Access.new }
let(:user) { create(:user) }
describe :allowed? do
subject { access.allowed?(user) }
context 'when the user cannot be found' do
before { Gitlab::LDAP::Person.stub(find_by_dn: nil) }
it { should be_false }
end
context 'when the user is found' do
before { Gitlab::LDAP::Person.stub(find_by_dn: :ldap_user) }
context 'and the Active Directory disabled flag is set' do
2014-05-14 17:13:06 +00:00
before { Gitlab::LDAP::Person.stub(active_directory_disabled?: true) }
2014-05-14 16:14:06 +00:00
it { should be_false }
end
context 'and the Active Directory disabled flag is not set' do
2014-05-14 17:13:06 +00:00
before { Gitlab::LDAP::Person.stub(active_directory_disabled?: false) }
2014-05-14 16:14:06 +00:00
it { should be_true }
end
end
end
end