Commit 410dd66f authored by James Lopez's avatar James Lopez

add more validation specs

parent 18f4dd4b
...@@ -4,9 +4,9 @@ describe LdapGroupLink do ...@@ -4,9 +4,9 @@ describe LdapGroupLink do
let(:klass) { described_class } let(:klass) { described_class }
let(:ldap_group_link) { build :ldap_group_link } let(:ldap_group_link) { build :ldap_group_link }
describe "validation" do describe 'validation' do
describe "cn" do describe 'cn' do
it "validates uniquiness based on group_id and provider" do it 'validates uniqueness based on group_id and provider' do
create(:ldap_group_link, cn: 'group1', group_id: 1, provider: 'ldapmain') create(:ldap_group_link, cn: 'group1', group_id: 1, provider: 'ldapmain')
group_link = build(:ldap_group_link, group_link = build(:ldap_group_link,
...@@ -22,13 +22,36 @@ describe LdapGroupLink do ...@@ -22,13 +22,36 @@ describe LdapGroupLink do
end end
end end
describe 'filter' do
it 'validates uniqueness based on group_id and provider' do
create(:ldap_group_link, filter: '(a=b)', group_id: 1, provider: 'ldapmain', cn: nil)
group_link = build(:ldap_group_link,
filter: '(a=b)', group_id: 1, provider: 'ldapmain', cn: nil)
expect(group_link).not_to be_valid
group_link.group_id = 2
expect(group_link).to be_valid
group_link.group_id = 1
group_link.provider = 'ldapalt'
expect(group_link).to be_valid
end
it 'validates the LDAP filter' do
link = build(:ldap_group_link, filter: 'invalid', group_id: 1, provider: 'ldapmain', cn: nil)
expect(link).not_to be_valid
end
end
describe 'provider' do describe 'provider' do
it "shows the set value" do it 'shows the set value' do
ldap_group_link.provider = '1235' ldap_group_link.provider = '1235'
expect( ldap_group_link.provider ).to eql '1235' expect( ldap_group_link.provider ).to eql '1235'
end end
it "defaults to the first ldap server if empty" do it 'defaults to the first ldap server if empty' do
expect( klass.new.provider ).to eql Gitlab::LDAP::Config.providers.first expect( klass.new.provider ).to eql Gitlab::LDAP::Config.providers.first
end end
end end
......
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