Skip to content
Extraits de code Groupes Projets
Non vérifiée Valider f212b51f rédigé par cmrd Senya's avatar cmrd Senya Validation de Benjamin Neff
Parcourir les fichiers

Check for user existence on aspect membership destruction

parent a36d22d7
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -11,9 +11,7 @@ class AspectMembership < ApplicationRecord
has_one :person, :through => :contact
before_destroy do
if self.contact && self.contact.aspects.size == 1
self.user.disconnect(self.contact)
end
user&.disconnect(contact) if contact&.aspects&.size == 1
true
end
......
......@@ -26,5 +26,13 @@ describe AspectMembership, :type => :model do
alice.add_contact_to_aspect(contact, aspect)
aspect_membership.destroy
end
it "doesn't fail destruction if the user entry was deleted in prior" do
aspect_membership.user.delete
id = aspect_membership.id
expect { AspectMembership.find(id).destroy }.not_to raise_error
expect(AspectMembership.where(id: id)).not_to exist
end
end
end
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter