Unverified Commit 973e9d98 authored by Senya's avatar Senya Committed by Benjamin Neff

Raise sensible error message when user is missing

That's for the case when podmin has messed up the database
parent f212b51f
......@@ -34,6 +34,7 @@ class User
logger.info "event=disconnect user=#{diaspora_handle} target=#{contact.person.diaspora_handle}"
if contact.person.local?
raise "FATAL: user entry is missing from the DB. Aborting" if contact.person.owner.nil?
contact.person.owner.disconnected_by(contact.user.person)
else
ContactRetraction.for(contact).defer_dispatch(self)
......
......@@ -104,6 +104,16 @@ describe User::Connecting, type: :model do
alice.disconnect(contact)
}.to change(contact.aspects, :count).from(2).to(0)
end
it "raises when a contact for an improperly deleted user was passed" do
contact = alice.contact_for(bob.person)
bob.delete
expect {
alice.disconnect(contact)
}.to raise_error "FATAL: user entry is missing from the DB. Aborting"
expect(Contact.where(id: contact.id)).to exist
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