Skip to content
Extraits de code Groupes Projets
Valider f4459488 rédigé par Benjamin Neff's avatar Benjamin Neff
Parcourir les fichiers

allow other people to share with a user who ignores them

otherwise we have data-inconsistency if the user stops ignoring the
person.
parent 3dd2f215
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -118,7 +118,8 @@ class Contact < ActiveRecord::Base
end
def not_blocked_user
errors.add(:base, "Cannot connect to an ignored user") if user && user.blocks.where(person_id: person_id).exists?
if receiving && user && user.blocks.where(person_id: person_id).exists?
errors.add(:base, "Cannot connect to an ignored user")
end
end
end
......@@ -62,14 +62,21 @@ describe Contact, type: :model do
end
describe "#not_blocked_user" do
it "add error if potential contact is blocked by user" do
it "adds an error when start sharing with a blocked person" do
alice.blocks.create(person: eve.person)
bad_contact = alice.contacts.create(person: eve.person)
bad_contact = alice.contacts.create(person: eve.person, receiving: true)
expect(bad_contact).not_to be_valid
expect(bad_contact.errors.full_messages.count).to eq(1)
expect(bad_contact.errors.full_messages.first).to eq("Cannot connect to an ignored user")
end
it "is valid when a blocked person starts sharing with the user" do
alice.blocks.create(person: eve.person)
bad_contact = alice.contacts.create(person: eve.person, receiving: false, sharing: true)
expect(bad_contact).to be_valid
end
end
end
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter