Merge pull request #9054 from mfo/US/fix-avis-termine-not-accessible
correctif(expert/avis#index): ETQ expert, je veux retrouver mes avis donnés sur des dossiers traités
This commit is contained in:
commit
4d877c6911
4 changed files with 46 additions and 10 deletions
|
@ -13,7 +13,10 @@ module Experts
|
||||||
DONNES_STATUS = 'donnes'
|
DONNES_STATUS = 'donnes'
|
||||||
|
|
||||||
def index
|
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)
|
@avis_by_procedure = avis.to_a.group_by(&:procedure)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
%ul.procedure-list
|
%ul.procedure-list
|
||||||
- @avis_by_procedure.each do |p, procedure_avis|
|
- @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
|
.flex
|
||||||
= link_to instructeur_procedure_path(p), class: 'procedure-logo-link' do
|
= link_to instructeur_procedure_path(p), class: 'procedure-logo-link' do
|
||||||
.procedure-logo{ style: "background-image: url(#{p.logo_url})" }
|
.procedure-logo{ style: "background-image: url(#{p.logo_url})" }
|
||||||
|
@ -16,17 +16,17 @@
|
||||||
= link_to(p.libelle, procedure_expert_avis_index_path(p), class: "fr-link fr-ml-1w")
|
= link_to(p.libelle, procedure_expert_avis_index_path(p), class: "fr-link fr-ml-1w")
|
||||||
|
|
||||||
%ul.procedure-stats.flex
|
%ul.procedure-stats.flex
|
||||||
%li
|
%li.avis-a-donner
|
||||||
%object
|
%object
|
||||||
= link_to(procedure_expert_avis_index_path(p, statut: Instructeurs::AvisController::A_DONNER_STATUS)) do
|
= 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
|
- if without_answer_count > 0
|
||||||
%span.notifications{ 'aria-label': "notifications" }
|
%span.notifications{ 'aria-label': "notifications" }
|
||||||
.stats-number
|
.stats-number
|
||||||
= without_answer_count
|
= without_answer_count
|
||||||
.stats-legend
|
.stats-legend
|
||||||
avis à donner
|
avis à donner
|
||||||
%li
|
%li.avis-donne
|
||||||
%object
|
%object
|
||||||
= link_to(procedure_expert_avis_index_path(p, statut: Instructeurs::AvisController::DONNES_STATUS)) do
|
= 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
|
- with_answer_count = procedure_avis.select { |a| a.answer.present? }.size
|
||||||
|
|
|
@ -28,7 +28,9 @@ describe Experts::AvisController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#index' do
|
describe '#index' do
|
||||||
|
context 'nominal' do
|
||||||
before { get :index }
|
before { get :index }
|
||||||
|
|
||||||
it do
|
it do
|
||||||
expect(response).to have_http_status(:success)
|
expect(response).to have_http_status(:success)
|
||||||
expect(assigns(:avis_by_procedure).keys).to match_array(procedure)
|
expect(assigns(:avis_by_procedure).keys).to match_array(procedure)
|
||||||
|
@ -36,6 +38,27 @@ describe Experts::AvisController, type: :controller do
|
||||||
end
|
end
|
||||||
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
|
||||||
|
|
||||||
describe '#procedure' do
|
describe '#procedure' do
|
||||||
context 'without filter' do
|
context 'without filter' do
|
||||||
let!(:oldest_avis_without_answer) { create(:avis, dossier: dossier, claimant: claimant, experts_procedure: experts_procedure, created_at: 2.years.ago) }
|
let!(:oldest_avis_without_answer) { create(:avis, dossier: dossier, claimant: claimant, experts_procedure: experts_procedure, created_at: 2.years.ago) }
|
||||||
|
|
|
@ -17,6 +17,16 @@ describe 'experts/avis/index', type: :view do
|
||||||
expect(subject).to have_text("avis à donner")
|
expect(subject).to have_text("avis à donner")
|
||||||
end
|
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
|
context 'when the dossier is deleted by instructeur' do
|
||||||
before do
|
before do
|
||||||
avis.dossier.update!(state: "accepte", hidden_by_administration_at: Time.zone.now.beginning_of_day.utc)
|
avis.dossier.update!(state: "accepte", hidden_by_administration_at: Time.zone.now.beginning_of_day.utc)
|
||||||
|
|
Loading…
Reference in a new issue