Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ETQ instructeur, je vois un badge Corrigé lorsque le dossier a été corrigé #9936

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/helpers/dossier_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ def pending_correction_badge(for_profile, html_class: nil)
tag.span(Dossier.human_attribute_name("pending_correction.#{for_profile}"), class: ['fr-badge fr-badge--sm fr-badge--warning super', html_class], role: 'status')
end

def correction_resolved_badge
tag.span(Dossier.human_attribute_name("pending_correction.resolved"), class: ['fr-badge fr-badge--sm fr-badge--success super'], role: 'status')
def correction_resolved_badge(html_class: nil)
tag.span(Dossier.human_attribute_name("pending_correction.resolved"), class: ['fr-badge fr-badge--sm fr-badge--success super', html_class], role: 'status')
end

def demandeur_dossier(dossier)
Expand Down
4 changes: 4 additions & 0 deletions app/models/concerns/dossier_correctable_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ def pending_correction?
pending_corrections.exists?
end

def last_correction_resolved?
corrections.last&.resolved?
end

def resolve_pending_correction
pending_correction&.resolve
end
Expand Down
6 changes: 6 additions & 0 deletions app/services/dossier_projection_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ def pending_correction?

corrections.any? { _1[:resolved_at].nil? }
end

def resolved_corrections?
return false if corrections.blank?

corrections.all? { _1[:resolved_at].present? }
end
end
end

Expand Down
5 changes: 4 additions & 1 deletion app/views/instructeurs/dossiers/_header_top.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
= procedure_badge(dossier.procedure)

= status_badge(dossier.state)
= pending_correction_badge(:for_instructeur) if dossier.pending_correction?
- if dossier.pending_correction?
= pending_correction_badge(:for_instructeur)
- elsif dossier.en_construction? && dossier.last_correction_resolved?
= correction_resolved_badge
= render Instructeurs::SVASVRDecisionBadgeComponent.new(projection_or_dossier: dossier, procedure: dossier.procedure, with_label: true)


Expand Down
5 changes: 4 additions & 1 deletion app/views/instructeurs/procedures/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,10 @@

%td.status-col
- status = [status_badge(p.state)]
- status << pending_correction_badge(:for_instructeur, html_class: "fr-mt-1v") if p.pending_correction?
- if p.pending_correction?
- status << pending_correction_badge(:for_instructeur, html_class: "fr-mt-1v")
- elsif p.state.to_sym == :en_construction && p.resolved_corrections?
- status << correction_resolved_badge(html_class: "fr-mt-1v")
= link_to_if(p.hidden_by_administration_at.blank?, safe_join(status), path, class: class_names("cell-link": true, "fr-py-0": status.many?))

- if @procedure.sva_svr_enabled?
Expand Down
3 changes: 3 additions & 0 deletions spec/services/dossier_projection_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -258,16 +258,19 @@
before { create(:dossier_correction, dossier:) }

it { expect(subject.pending_correction?).to be(true) }
it { expect(subject.resolved_corrections?).to eq(false) }
end

context "when dossier has a resolved correction" do
before { create(:dossier_correction, :resolved, dossier:) }

it { expect(subject.pending_correction?).to eq(false) }
it { expect(subject.resolved_corrections?).to eq(true) }
end

context "when dossier has no correction at all" do
it { expect(subject.pending_correction?).to eq(false) }
it { expect(subject.resolved_corrections?).to eq(false) }
end
end
end
Expand Down
12 changes: 12 additions & 0 deletions spec/views/instructeur/dossiers/show.html.haml_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@

it { expect(subject).to have_button('Passer en instruction', disabled: false) }

it 'shows the correction badge' do
expect(subject).to have_selector('.fr-badge--warning', text: "en attente")
end

context 'with procedure blocking pending correction' do
before { Flipper.enable(:blocking_pending_correction, dossier.procedure) }

Expand All @@ -79,6 +83,14 @@
end
end
end

context 'with resolved correction' do
before { create(:dossier_correction, dossier:, resolved_at: 1.minute.ago) }

it 'shows the resolved badge' do
expect(subject).to have_selector('.fr-badge--success', text: "corrigé")
end
end
end

context 'en_instruction' do
Expand Down