[Fix #1619] Do not consider invitations to deleted dossiers

This commit is contained in:
Frederic Merizen 2018-03-14 18:57:56 +01:00
parent dcfe3070dd
commit 610058c534
2 changed files with 25 additions and 0 deletions

View file

@ -10,4 +10,11 @@ class Invite < ApplicationRecord
validates :email, uniqueness: { scope: :dossier_id }
validates :email, format: { with: Devise.email_regexp, message: "n'est pas valide" }, allow_nil: true
# #1619 When an administrateur deletes a `Procedure`, its `hidden_at` field, and
# the `hidden_at` field of its `Dossier`s, get set, effectively removing the Procedure
# and Dossier from their respective `default_scope`s.
# Therefore, we also remove `Invite`s for such effectively deleted `Dossier`s
# from their default scope.
default_scope { joins(:dossier).where(dossiers: { hidden_at: nil }) }
end