From 0213ad018a917254959f841f39e96db35ab4d736 Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 16 May 2023 14:41:02 +0200 Subject: [PATCH 1/4] =?UTF-8?q?bug(expert/avis#index):=20ETQ=20expert,=20j?= =?UTF-8?q?e=20veux=20retrouver=20mes=20avis=20donn=C3=A9s=20sur=20des=20d?= =?UTF-8?q?ossiers=20trait=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../experts/avis_controller_spec.rb | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/spec/controllers/experts/avis_controller_spec.rb b/spec/controllers/experts/avis_controller_spec.rb index c676f58f2..20873a21e 100644 --- a/spec/controllers/experts/avis_controller_spec.rb +++ b/spec/controllers/experts/avis_controller_spec.rb @@ -28,11 +28,34 @@ describe Experts::AvisController, type: :controller do end describe '#index' do - before { get :index } - it do - expect(response).to have_http_status(:success) - expect(assigns(:avis_by_procedure).keys).to match_array(procedure) - expect(assigns(:avis_by_procedure).values.flatten).to match_array([avis_without_answer, avis_with_answer]) + context 'nominal' do + before { get :index } + + it do + expect(response).to have_http_status(:success) + expect(assigns(:avis_by_procedure).keys).to match_array(procedure) + expect(assigns(:avis_by_procedure).values.flatten).to match_array([avis_without_answer, avis_with_answer]) + end + end + + context 'avis on termine dossier' do + let(:another_experts_procedure) { create(:experts_procedure, expert:, procedure: another_procedure) } + let(:dossier_termine) { create(:dossier, :accepte, procedure: another_procedure) } + let(:another_avis_without_answer) { create(:avis, claimant:, dossier: dossier_termine, experts_procedure: another_experts_procedure) } + let(:another_avis_with_answer) { create(:avis, claimant:, dossier: dossier_termine, experts_procedure: another_experts_procedure, answer: 'yop') } + + before do + another_experts_procedure + dossier_termine + another_avis_without_answer + another_avis_with_answer + get :index + end + + it do + expect(response).to have_http_status(:success) + expect(assigns(:avis_by_procedure).keys).to match_array([procedure, another_procedure]) + end end end From 1417d0e873db4e351daec57bb60cbc52df80006d Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 16 May 2023 14:44:54 +0200 Subject: [PATCH 2/4] =?UTF-8?q?correctif(expert/avis#index):=20ETQ=20exper?= =?UTF-8?q?t,=20je=20veux=20retrouver=20mes=20avis=20donn=C3=A9s=20sur=20d?= =?UTF-8?q?es=20dossiers=20trait=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/experts/avis_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/experts/avis_controller.rb b/app/controllers/experts/avis_controller.rb index 7320afb24..3cdc72661 100644 --- a/app/controllers/experts/avis_controller.rb +++ b/app/controllers/experts/avis_controller.rb @@ -13,7 +13,7 @@ module Experts DONNES_STATUS = 'donnes' def index - avis = current_expert.avis.not_revoked.not_termine.includes(dossier: [groupe_instructeur: :procedure]).not_hidden_by_administration + avis = current_expert.avis.not_revoked.includes(dossier: [groupe_instructeur: :procedure]).not_hidden_by_administration @avis_by_procedure = avis.to_a.group_by(&:procedure) end From d2e30911f71cf0ad38270cc5083c78f910ff2e6d Mon Sep 17 00:00:00 2001 From: Martin Date: Mon, 22 May 2023 10:49:25 +0200 Subject: [PATCH 3/4] bug(compteurs.avis.a.donner): ETQ expert, je ne souhaite pas avoir a donner un avis sur un dossier termine --- app/controllers/experts/avis_controller.rb | 5 ++++- app/views/experts/avis/index.html.haml | 6 +++--- spec/views/experts/avis/index.html.haml_spec.rb | 10 ++++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/controllers/experts/avis_controller.rb b/app/controllers/experts/avis_controller.rb index 3cdc72661..56f10b2ca 100644 --- a/app/controllers/experts/avis_controller.rb +++ b/app/controllers/experts/avis_controller.rb @@ -13,7 +13,10 @@ module Experts DONNES_STATUS = 'donnes' def index - avis = current_expert.avis.not_revoked.includes(dossier: [groupe_instructeur: :procedure]).not_hidden_by_administration + avis = current_expert.avis + .not_revoked + .includes(dossier: [groupe_instructeur: :procedure]) + .not_hidden_by_administration @avis_by_procedure = avis.to_a.group_by(&:procedure) end diff --git a/app/views/experts/avis/index.html.haml b/app/views/experts/avis/index.html.haml index 535c0e49d..3ccda63ca 100644 --- a/app/views/experts/avis/index.html.haml +++ b/app/views/experts/avis/index.html.haml @@ -5,7 +5,7 @@ %ul.procedure-list - @avis_by_procedure.each do |p, procedure_avis| - %li.procedure-item.flex.align-start.fr-my-3w.fr-p-2w + %li.procedure-item.flex.align-start.fr-my-3w.fr-p-2w{ id: dom_id(p) } .flex = link_to instructeur_procedure_path(p), class: 'procedure-logo-link' do .procedure-logo{ style: "background-image: url(#{p.logo_url})" } @@ -16,7 +16,7 @@ = link_to(p.libelle, procedure_expert_avis_index_path(p), class: "fr-link fr-ml-1w") %ul.procedure-stats.flex - %li + %li.avis-a-donner %object = link_to(procedure_expert_avis_index_path(p, statut: Instructeurs::AvisController::A_DONNER_STATUS)) do - without_answer_count = procedure_avis.select { |a| a.answer.nil? }.size @@ -26,7 +26,7 @@ = without_answer_count .stats-legend avis à donner - %li + %li.avis-donne %object = link_to(procedure_expert_avis_index_path(p, statut: Instructeurs::AvisController::DONNES_STATUS)) do - with_answer_count = procedure_avis.select { |a| a.answer.present? }.size diff --git a/spec/views/experts/avis/index.html.haml_spec.rb b/spec/views/experts/avis/index.html.haml_spec.rb index b7de4602e..54cd86c6f 100644 --- a/spec/views/experts/avis/index.html.haml_spec.rb +++ b/spec/views/experts/avis/index.html.haml_spec.rb @@ -17,6 +17,16 @@ describe 'experts/avis/index', type: :view do expect(subject).to have_text("avis à donner") end + context 'dossier is termine' do + before do + avis.dossier.update!(state: "accepte") + end + + it 'doesn’t count avis a donner when dossier is termine' do + expect(subject).to have_selector("##{dom_id(procedure)} .avis-a-donner .stats-number", text: 0) + end + end + context 'when the dossier is deleted by instructeur' do before do avis.dossier.update!(state: "accepte", hidden_by_administration_at: Time.zone.now.beginning_of_day.utc) From 9b86fdf8535a15163d7d8bda8c3bcc60faa3a3e0 Mon Sep 17 00:00:00 2001 From: Martin Date: Mon, 22 May 2023 10:50:26 +0200 Subject: [PATCH 4/4] =?UTF-8?q?correctif(compteurs.avis.a.donner):=20ETQ?= =?UTF-8?q?=20expert,=20les=20compteurs=20d'avis=20=C3=A0=20donner=20n'int?= =?UTF-8?q?=C3=A8grent=20pas=20les=20avis=20=C3=A0=20donner=20sur=20des=20?= =?UTF-8?q?dossiers=20termin=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/experts/avis/index.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/experts/avis/index.html.haml b/app/views/experts/avis/index.html.haml index 3ccda63ca..b3a27f96d 100644 --- a/app/views/experts/avis/index.html.haml +++ b/app/views/experts/avis/index.html.haml @@ -19,7 +19,7 @@ %li.avis-a-donner %object = link_to(procedure_expert_avis_index_path(p, statut: Instructeurs::AvisController::A_DONNER_STATUS)) do - - without_answer_count = procedure_avis.select { |a| a.answer.nil? }.size + - without_answer_count = procedure_avis.select { _1.answer.nil? }.reject{ _1.dossier.termine?}.size - if without_answer_count > 0 %span.notifications{ 'aria-label': "notifications" } .stats-number