Merge pull request #5028 from betagouv/feat/demandeur-dossiers

Nom du demandeur dans liste des dossiers usagers
This commit is contained in:
Keirua 2020-04-10 14:40:33 +02:00 committed by GitHub
commit 5e1e11d802
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 0 deletions

View file

@ -1,4 +1,6 @@
module DossierHelper
include EtablissementHelper
def button_or_label_class(dossier)
if dossier.accepte?
'accepted'
@ -101,6 +103,18 @@ module DossierHelper
content_tag(:span, status_text, class: "label #{status_class} ")
end
def demandeur_dossier(dossier)
if dossier.procedure.for_individual?
"#{dossier&.individual&.nom} #{dossier&.individual&.prenom}"
else
if dossier.etablissement.present?
raison_sociale_or_name(dossier.etablissement)
else
""
end
end
end
private
def dinum_instance?

View file

@ -32,6 +32,8 @@
%th.notification-col
%th.number-col Nº dossier
%th Démarche
- if @dossiers.count > 1
%th Demandeur
%th.status-col Statut
%th.updated-at-col Mis à jour
%th
@ -47,6 +49,9 @@
%td
= link_to(url_for_dossier(dossier), class: 'cell-link') do
= procedure_libelle(dossier.procedure)
- if @dossiers.count > 1
%td.number-col
= demandeur_dossier(dossier)
%td.status-col
= link_to(url_for_dossier(dossier), class: 'cell-link') do
= status_badge(dossier.state)

View file

@ -38,6 +38,40 @@ RSpec.describe DossierHelper, type: :helper do
end
end
describe ".demandeur_dossier" do
subject { demandeur_dossier(dossier) }
let(:individual) { create(:individual) }
let(:etablissement) { create(:etablissement) }
let(:dossier) { create(:dossier, procedure: procedure, individual: individual, etablissement: etablissement) }
context "when the dossier is for an individual" do
let(:procedure) { create(:simple_procedure, :for_individual) }
context "when the individual is not provided" do
let(:individual) { nil }
it { is_expected.to be_blank }
end
context "when the individual has name information" do
it { is_expected.to eq "#{individual.nom} #{individual.prenom}" }
end
end
context "when the dossier is for a company" do
let(:procedure) { create(:procedure, for_individual: false) }
context "when the company is not provided" do
let(:etablissement) { nil }
it { is_expected.to be_blank }
end
context "when the company has name information" do
it { is_expected.to eq raison_sociale_or_name(etablissement) }
end
end
end
describe ".dossier_submission_is_closed?" do
let(:dossier) { create(:dossier, state: state) }
let(:state) { Dossier.states.fetch(:brouillon) }