diff options
author | Constance Okoghenun <cokoghenun@gitlab.com> | 2018-01-09 00:50:54 +0100 |
---|---|---|
committer | Constance Okoghenun <cokoghenun@gitlab.com> | 2018-01-09 00:50:54 +0100 |
commit | 85e8acedaf1d4e51335c59a0efa2f95576a4fde3 (patch) | |
tree | 9b21d76626568158cf746e2a7eb4853efe3aa0d5 /spec/models/identity_spec.rb | |
parent | cdcade0dd4e748bcf0119b307c06993e0669f507 (diff) | |
parent | bd50ecbad8c00e7c9ab5c60fa8bc839a8905b4ab (diff) | |
download | gitlab-ce-move-project-dropdown.tar.gz |
Resolved conflictsmove-project-dropdown
Diffstat (limited to 'spec/models/identity_spec.rb')
-rw-r--r-- | spec/models/identity_spec.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/models/identity_spec.rb b/spec/models/identity_spec.rb index a45a6088831..7c66c98231b 100644 --- a/spec/models/identity_spec.rb +++ b/spec/models/identity_spec.rb @@ -44,4 +44,31 @@ describe Identity do end end end + + context 'callbacks' do + context 'before_save' do + describe 'normalizes extern uid' do + let!(:ldap_identity) { create(:identity, provider: 'ldapmain', extern_uid: 'uid=john smith,ou=people,dc=example,dc=com') } + + it 'if extern_uid changes' do + expect(ldap_identity).not_to receive(:ensure_normalized_extern_uid) + ldap_identity.save + end + + it 'if current_uid is nil' do + expect(ldap_identity).to receive(:ensure_normalized_extern_uid) + + ldap_identity.update(extern_uid: nil) + + expect(ldap_identity.extern_uid).to be_nil + end + + it 'if extern_uid changed and not nil' do + ldap_identity.update(extern_uid: 'uid=john1,ou=PEOPLE,dc=example,dc=com') + + expect(ldap_identity.extern_uid).to eq 'uid=john1,ou=people,dc=example,dc=com' + end + end + end + end end |