summaryrefslogtreecommitdiff
path: root/spec/models/identity_spec.rb
diff options
context:
space:
mode:
authorFrancisco Javier López <fjlopez@gitlab.com>2018-02-15 09:27:38 +0000
committerDouwe Maan <douwe@gitlab.com>2018-02-15 09:27:38 +0000
commit26af0e2d601401114a0574203a56f5f71417adf3 (patch)
tree71c316455f3e11444b5d24b5ccee302c81cde238 /spec/models/identity_spec.rb
parent16ca6914f622ce7ddf116173293c6f49a93092bc (diff)
downloadgitlab-ce-26af0e2d601401114a0574203a56f5f71417adf3.tar.gz
Fixed user synced attributes metadata after removing current provider
Diffstat (limited to 'spec/models/identity_spec.rb')
-rw-r--r--spec/models/identity_spec.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/models/identity_spec.rb b/spec/models/identity_spec.rb
index 7c66c98231b..a5ce245c21d 100644
--- a/spec/models/identity_spec.rb
+++ b/spec/models/identity_spec.rb
@@ -70,5 +70,38 @@ describe Identity do
end
end
end
+
+ context 'after_destroy' do
+ let!(:user) { create(:user) }
+ let(:ldap_identity) { create(:identity, provider: 'ldapmain', extern_uid: 'uid=john smith,ou=people,dc=example,dc=com', user: user) }
+ let(:ldap_user_synced_attributes) { { provider: 'ldapmain', name_synced: true, email_synced: true } }
+ let(:other_provider_user_synced_attributes) { { provider: 'other', name_synced: true, email_synced: true } }
+
+ describe 'if user synced attributes metadada provider' do
+ context 'matches the identity provider ' do
+ it 'removes the user synced attributes' do
+ user.create_user_synced_attributes_metadata(ldap_user_synced_attributes)
+
+ expect(user.user_synced_attributes_metadata.provider).to eq 'ldapmain'
+
+ ldap_identity.destroy
+
+ expect(user.reload.user_synced_attributes_metadata).to be_nil
+ end
+ end
+
+ context 'does not matche the identity provider' do
+ it 'does not remove the user synced attributes' do
+ user.create_user_synced_attributes_metadata(other_provider_user_synced_attributes)
+
+ expect(user.user_synced_attributes_metadata.provider).to eq 'other'
+
+ ldap_identity.destroy
+
+ expect(user.reload.user_synced_attributes_metadata.provider).to eq 'other'
+ end
+ end
+ end
+ end
end
end