Merge pull request #6206 from tchak/fix-deleted-user

Fix dossier deleted user display
This commit is contained in:
LeSim 2021-05-18 11:40:53 +02:00 committed by GitHub
commit c869ea3d3c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 5 deletions

View file

@ -63,7 +63,6 @@ class Dossier < ApplicationRecord
has_one :etablissement, dependent: :destroy has_one :etablissement, dependent: :destroy
has_one :individual, validate: false, dependent: :destroy has_one :individual, validate: false, dependent: :destroy
has_one :attestation, dependent: :destroy has_one :attestation, dependent: :destroy
has_one :france_connect_information, through: :user
# FIXME: some dossiers have more than one attestation # FIXME: some dossiers have more than one attestation
has_many :attestations, dependent: :destroy has_many :attestations, dependent: :destroy
@ -88,6 +87,7 @@ class Dossier < ApplicationRecord
belongs_to :groupe_instructeur, optional: true belongs_to :groupe_instructeur, optional: true
belongs_to :revision, class_name: 'ProcedureRevision', optional: false belongs_to :revision, class_name: 'ProcedureRevision', optional: false
belongs_to :user, optional: true belongs_to :user, optional: true
has_one :france_connect_information, through: :user
has_one :procedure, through: :revision has_one :procedure, through: :revision
has_many :types_de_champ, through: :revision has_many :types_de_champ, through: :revision
@ -340,7 +340,7 @@ class Dossier < ApplicationRecord
accepts_nested_attributes_for :individual accepts_nested_attributes_for :individual
delegate :siret, :siren, to: :etablissement, allow_nil: true delegate :siret, :siren, to: :etablissement, allow_nil: true
delegate :france_connect_information, to: :user delegate :france_connect_information, to: :user, allow_nil: true
before_save :build_default_champs, if: Proc.new { revision_id_was.nil? } before_save :build_default_champs, if: Proc.new { revision_id_was.nil? }
before_save :update_search_terms before_save :update_search_terms

View file

@ -3,7 +3,7 @@
%h2 Identité du demandeur %h2 Identité du demandeur
= render partial: "shared/dossiers/user_infos", locals: { user: @dossier.user } = render partial: "shared/dossiers/user_infos", locals: { user_deleted: @dossier.user_deleted?, email: @dossier.user_email_for(:display) }
- if @dossier.etablissement.present? - if @dossier.etablissement.present?
= render partial: "shared/dossiers/identite_entreprise", locals: { etablissement: @dossier.etablissement, profile: 'instructeur' } = render partial: "shared/dossiers/identite_entreprise", locals: { etablissement: @dossier.etablissement, profile: 'instructeur' }

View file

@ -7,7 +7,7 @@
.card .card
- if dossier.france_connect_information.present? - if dossier.france_connect_information.present?
= render partial: "shared/dossiers/france_connect_informations", locals: { user_information: dossier.france_connect_information } = render partial: "shared/dossiers/france_connect_informations", locals: { user_information: dossier.france_connect_information }
= render partial: "shared/dossiers/user_infos", locals: { user: dossier.user } = render partial: "shared/dossiers/user_infos", locals: { user_deleted: dossier.user_deleted?, email: dossier.user_email_for(:display) }
- if dossier.etablissement.present? - if dossier.etablissement.present?
= render partial: "shared/dossiers/identite_entreprise", locals: { etablissement: dossier.etablissement, profile: profile } = render partial: "shared/dossiers/identite_entreprise", locals: { etablissement: dossier.etablissement, profile: profile }

View file

@ -2,4 +2,4 @@
%tbody %tbody
%tr %tr
%th.libelle Email : %th.libelle Email :
%td= user.email %td= user_deleted ? "#{email} (lusager a supprimé son compte)" : email

View file

@ -348,6 +348,7 @@ describe User, type: :model do
expect(dossier_termine.user).to be_nil expect(dossier_termine.user).to be_nil
expect(dossier_termine.user_email_for(:display)).to eq(user.email) expect(dossier_termine.user_email_for(:display)).to eq(user.email)
expect(dossier_termine.valid?).to be_truthy expect(dossier_termine.valid?).to be_truthy
expect(dossier_termine.france_connect_information).to be_nil
expect { dossier_termine.user_email_for(:notification) }.to raise_error(RuntimeError) expect { dossier_termine.user_email_for(:notification) }.to raise_error(RuntimeError)
expect(User.find_by(id: user.id)).to be_nil expect(User.find_by(id: user.id)).to be_nil