hide decision displayed in badge for user

This commit is contained in:
Lisa Durand 2024-03-27 11:44:35 +01:00
parent e486f789f6
commit 8fe9b174eb
7 changed files with 53 additions and 7 deletions

View file

@ -78,6 +78,17 @@ module DossierHelper
end
end
def status_badge_user(dossier, alignment_class = '')
if dossier.hide_info_with_accuse_lecture
tag.span 'traité', role: 'status', class: class_names(
'fr-badge fr-badge--sm fr-badge--no-icon' => true,
alignment_class => true
)
else
status_badge(dossier.state, alignment_class)
end
end
def status_badge(state, alignment_class = '')
status_text = dossier_display_state(state, lower: true)
tag.span status_text, role: 'status', class: class_names(

View file

@ -1,6 +1,6 @@
%h1
= procedure_libelle(dossier.procedure)
= status_badge(dossier.state, 'super')
= status_badge_user(dossier, 'super')
%h2
= t('views.users.dossiers.show.header.dossier_number', dossier_id: dossier.id)
= t('views.users.dossiers.show.header.created_date', date_du_dossier: I18n.l(dossier.created_at))

View file

@ -44,7 +44,7 @@
%span.fr-badge.fr-badge--sm.fr-badge--warning
= t('views.users.dossiers.dossiers_list.deleted_badge')
- else
= status_badge(dossier.state, 'fr-mb-1w')
= status_badge_user(dossier, 'fr-mb-1w')
- if dossier.pending_correction?
%br

View file

@ -2,7 +2,7 @@
.fr-container
%h1
= dossier.procedure.libelle
= status_badge(dossier.state, 'super')
= status_badge_user(dossier, 'super')
= pending_correction_badge(:for_user) if dossier.pending_correction?
%h2
= t('views.users.dossiers.show.header.dossier_number', dossier_id: dossier.id)

View file

@ -96,6 +96,15 @@ describe PiecesJustificativesService do
it { expect(subject).to be_empty }
end
context 'with a motivation and procedure with accuse de lecture' do
let(:dossier) { create :dossier, :accepte, :with_motivation, procedure: create(:procedure, :accuse_lecture) }
it 'still displays the motivation text for the instructeur and the correct dossier state' do
expect(subject).to have_content(dossier.motivation)
expect(rendered).to have_selector('.fr-badge', text: 'accepté', count: 1)
end
end
context 'with an attestation' do
let(:dossier) { create(:dossier, :with_attestation) }
let!(:witness) { create(:dossier, :with_attestation) }

View file

@ -1,10 +1,13 @@
describe 'users/dossiers/index', type: :view do
let(:user) { create(:user) }
let(:procedure_accuse_lecture) { create(:procedure, :accuse_lecture) }
let(:dossier_brouillon) { create(:dossier, state: Dossier.states.fetch(:brouillon), user: user) }
let(:dossier_en_construction) { create(:dossier, state: Dossier.states.fetch(:en_construction), user: user) }
let(:dossier_en_construction_with_accuse_lecture) { create(:dossier, state: Dossier.states.fetch(:en_construction), user: user, procedure: procedure_accuse_lecture) }
let(:dossier_termine) { create(:dossier, state: Dossier.states.fetch(:accepte), user: user) }
let(:dossier_termine_with_accuse_lecture) { create(:dossier, state: Dossier.states.fetch(:accepte), user: user, procedure: procedure_accuse_lecture) }
let(:dossiers_invites) { [] }
let(:user_dossiers) { Kaminari.paginate_array([dossier_brouillon, dossier_en_construction, dossier_termine]).page(1) }
let(:user_dossiers) { Kaminari.paginate_array([dossier_brouillon, dossier_en_construction, dossier_termine, dossier_en_construction_with_accuse_lecture, dossier_termine_with_accuse_lecture]).page(1) }
let(:statut) { 'en-cours' }
let(:filter) { DossiersFilter.new(user, ActionController::Parameters.new(random_param: 'random_param')) }
@ -28,7 +31,7 @@ describe 'users/dossiers/index', type: :view do
end
it 'affiche les dossiers' do
expect(rendered).to have_selector('.card', count: 3)
expect(rendered).to have_selector('.card', count: 5)
end
it 'affiche les informations des dossiers' do
@ -40,6 +43,9 @@ describe 'users/dossiers/index', type: :view do
expect(rendered).to have_text(dossier_en_construction.id.to_s)
expect(rendered).to have_text(dossier_en_construction.procedure.libelle)
expect(rendered).to have_link(dossier_en_construction.procedure.libelle, href: dossier_path(dossier_en_construction))
expect(rendered).to have_selector('.fr-badge', text: 'traité', count: 1)
expect(rendered).to have_selector('.fr-badge', text: 'en construction', count: 2)
end
it 'naffiche pas une alerte pour continuer à remplir un dossier' do
@ -132,13 +138,13 @@ describe 'users/dossiers/index', type: :view do
it "cache key depends on dossiers list" do
render
expect(rendered).to have_text(/3\s+en cours/)
expect(rendered).to have_text(/5\s+en cours/)
assign(:user_dossiers, Kaminari.paginate_array(user_dossiers.concat([create(:dossier, :en_construction, user: user)])).page(1))
user.reload
render
expect(rendered).to have_text(/4\s+en cours/)
expect(rendered).to have_text(/6\s+en cours/)
end
it "cache key dpeends on dossier invites" do

View file

@ -18,6 +18,26 @@ describe 'users/dossiers/show/header', type: :view do
expect(rendered).to have_link("Demande", href: demande_dossier_path(dossier))
end
context "when the procedure is with accuse de lecture with a dossier en construction" do
let(:procedure) { create(:procedure, :accuse_lecture) }
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
it "affiche les informations du dossier" do
expect(rendered).to have_text("Dossier nº #{dossier.id}")
expect(rendered).to have_text("en construction")
end
end
context "when the procedure is with accuse de lecture with a dossier termine" do
let(:procedure) { create(:procedure, :accuse_lecture) }
let(:dossier) { create(:dossier, :accepte, procedure: procedure) }
it "n'affiche pas les informations de décision" do
expect(rendered).to have_text("Dossier nº #{dossier.id}")
expect(rendered).to have_text("traité")
end
end
context "when the procedure is closed with a dossier en construction" do
let(:procedure) { create(:procedure, :closed) }
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }