diff --git a/app/models/dossier.rb b/app/models/dossier.rb index acb3b8db5..cd288cae0 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -63,7 +63,6 @@ class Dossier < ApplicationRecord has_one :etablissement, dependent: :destroy has_one :individual, validate: false, dependent: :destroy has_one :attestation, dependent: :destroy - has_one :france_connect_information, through: :user # FIXME: some dossiers have more than one attestation has_many :attestations, dependent: :destroy @@ -88,6 +87,7 @@ class Dossier < ApplicationRecord belongs_to :groupe_instructeur, optional: true belongs_to :revision, class_name: 'ProcedureRevision', optional: false belongs_to :user, optional: true + has_one :france_connect_information, through: :user has_one :procedure, through: :revision has_many :types_de_champ, through: :revision @@ -340,7 +340,7 @@ class Dossier < ApplicationRecord accepts_nested_attributes_for :individual 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 :update_search_terms diff --git a/app/views/instructeurs/dossiers/print.html.haml b/app/views/instructeurs/dossiers/print.html.haml index 25bfa2aec..656085d58 100644 --- a/app/views/instructeurs/dossiers/print.html.haml +++ b/app/views/instructeurs/dossiers/print.html.haml @@ -3,7 +3,7 @@ %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? = render partial: "shared/dossiers/identite_entreprise", locals: { etablissement: @dossier.etablissement, profile: 'instructeur' } diff --git a/app/views/shared/dossiers/_demande.html.haml b/app/views/shared/dossiers/_demande.html.haml index a4c45ec87..585a49319 100644 --- a/app/views/shared/dossiers/_demande.html.haml +++ b/app/views/shared/dossiers/_demande.html.haml @@ -7,7 +7,7 @@ .card - if dossier.france_connect_information.present? = 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? = render partial: "shared/dossiers/identite_entreprise", locals: { etablissement: dossier.etablissement, profile: profile } diff --git a/app/views/shared/dossiers/_user_infos.html.haml b/app/views/shared/dossiers/_user_infos.html.haml index bf003b719..5aed997d0 100644 --- a/app/views/shared/dossiers/_user_infos.html.haml +++ b/app/views/shared/dossiers/_user_infos.html.haml @@ -2,4 +2,4 @@ %tbody %tr %th.libelle Email : - %td= user.email + %td= user_deleted ? "#{email} (l‘usager a supprimé son compte)" : email diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 002f0b2d2..15401ff14 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -348,6 +348,7 @@ describe User, type: :model do expect(dossier_termine.user).to be_nil expect(dossier_termine.user_email_for(:display)).to eq(user.email) 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(User.find_by(id: user.id)).to be_nil