From d54133b09fdb0b2e589896dc8740bb8d0c99ed54 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer <contact@jacobvosmaer.nl> Date: Wed, 14 May 2014 18:14:06 +0200 Subject: [PATCH] Add spec for LDAP::Access#allowed? --- spec/lib/gitlab/ldap/ldap_access_spec.rb | 32 ++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 spec/lib/gitlab/ldap/ldap_access_spec.rb diff --git a/spec/lib/gitlab/ldap/ldap_access_spec.rb b/spec/lib/gitlab/ldap/ldap_access_spec.rb new file mode 100644 index 00000000000..e76cc4f2fde --- /dev/null +++ b/spec/lib/gitlab/ldap/ldap_access_spec.rb @@ -0,0 +1,32 @@ +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 + before { Gitlab::LDAP::Person.stub(ad_disabled?: true) } + + it { should be_false } + end + + context 'and the Active Directory disabled flag is not set' do + before { Gitlab::LDAP::Person.stub(ad_disabled?: false) } + + it { should be_true } + end + end + end +end -- GitLab