Merge pull request #3764 from betagouv/fix-gestionnaire-follow

gestionnaire: ignore when the gestionnaire already follows the dossier
This commit is contained in:
LeSim 2019-04-18 13:16:31 +02:00 committed by GitHub
commit 176be142cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -31,7 +31,18 @@ class Gestionnaire < ApplicationRecord
return
end
followed_dossiers << dossier
begin
followed_dossiers << dossier
rescue ActiveRecord::RecordNotUnique
# Altough we checked before the insertion that the gestionnaire wasn't
# already following this dossier, this was done at the Rails level:
# at the database level, the dossier was already followed, and a
# "invalid constraint" exception is raised.
#
# We can ignore this safely, as it means the goal is already reached:
# the gestionnaire follows the dossier.
return
end
end
def unfollow(dossier)