Merge pull request #8845 from demarches-simplifiees/remove-dossiers-termines-from-avis-views
[bug] retirer les notifications + compteur des avis pour les dossiers terminés
This commit is contained in:
commit
dde64415ae
4 changed files with 14 additions and 3 deletions
|
@ -13,7 +13,7 @@ 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.not_termine.includes(dossier: [groupe_instructeur: :procedure]).not_hidden_by_administration
|
||||
@avis_by_procedure = avis.to_a.group_by(&:procedure)
|
||||
end
|
||||
|
||||
|
@ -35,7 +35,7 @@ module Experts
|
|||
redirect_to(expert_all_avis_path, flash: { alert: "Vous n’avez pas accès à cette démarche." }) and return
|
||||
end
|
||||
|
||||
@avis_a_donner = expert_avis.without_answer
|
||||
@avis_a_donner = expert_avis.not_termine.without_answer
|
||||
@avis_donnes = expert_avis.with_answer
|
||||
|
||||
@statut = params[:statut].presence || A_DONNER_STATUS
|
||||
|
|
|
@ -59,6 +59,8 @@ class Avis < ApplicationRecord
|
|||
scope :en_construction_expired, -> { unscope(:joins).where(dossier: Dossier.en_construction_expired) }
|
||||
scope :not_hidden_by_administration, -> { where(dossiers: { hidden_by_administration_at: nil }) }
|
||||
scope :not_revoked, -> { where(revoked_at: nil) }
|
||||
scope :not_termine, -> { where.not(dossiers: { state: Dossier::TERMINE }) }
|
||||
|
||||
# The form allows subtmitting avis requests to several emails at once,
|
||||
# hence this virtual attribute.
|
||||
attr_accessor :emails
|
||||
|
|
|
@ -30,7 +30,7 @@ class Expert < ApplicationRecord
|
|||
@avis_summary
|
||||
else
|
||||
query = <<~EOF
|
||||
COUNT(*) FILTER (where answer IS NULL AND dossiers.hidden_by_administration_at IS NULL) AS unanswered,
|
||||
COUNT(*) FILTER (where answer IS NULL AND dossiers.hidden_by_administration_at IS NULL AND dossiers.state not in ('accepte', 'refuse', 'sans_suite')) AS unanswered,
|
||||
COUNT(*) AS total
|
||||
EOF
|
||||
result = avis.select(query)[0]
|
||||
|
|
|
@ -11,6 +11,8 @@ describe 'Inviting an expert:' do
|
|||
let(:champ) { dossier.champs_public.first }
|
||||
let(:avis) { create(:avis, dossier: dossier, claimant: instructeur, experts_procedure: experts_procedure, confidentiel: true) }
|
||||
let(:avis_with_question) { create(:avis, dossier: dossier, claimant: instructeur, experts_procedure: experts_procedure, confidentiel: true, question_label: 'Question ?') }
|
||||
let(:dossier_accepte) { create(:dossier, :accepte, procedure: procedure) }
|
||||
let(:avis_on_dossier_accepte) { create(:avis, dossier: dossier_accepte, claimant: instructeur, experts_procedure: experts_procedure, confidentiel: true) }
|
||||
|
||||
context 'when I don’t already have an account' do
|
||||
let(:password) { 'This is an expert password' }
|
||||
|
@ -58,12 +60,16 @@ describe 'Inviting an expert:' do
|
|||
|
||||
scenario 'I can give an answer' do
|
||||
avis # create avis
|
||||
avis_on_dossier_accepte # create avis
|
||||
login_as expert.user, scope: :user
|
||||
|
||||
visit expert_all_avis_path
|
||||
expect(page).to have_text('1 avis à donner')
|
||||
expect(page).to have_text('0 avis donnés')
|
||||
|
||||
expect(page).to have_selector('.badge', text: 1)
|
||||
expect(page).to have_selector('.notifications')
|
||||
|
||||
click_on '1 avis à donner'
|
||||
click_on avis.dossier.user.email
|
||||
within('.tabs') { click_on 'Avis' }
|
||||
|
@ -81,6 +87,9 @@ describe 'Inviting an expert:' do
|
|||
within('.fr-breadcrumb__list') { click_on 'Avis' }
|
||||
expect(page).to have_text('0 avis à donner')
|
||||
expect(page).to have_text('1 avis donné')
|
||||
|
||||
expect(page).not_to have_selector('.badge', text: 1)
|
||||
expect(page).not_to have_selector('.notifications')
|
||||
end
|
||||
|
||||
scenario 'I can give a yes/no answer to a question' do
|
||||
|
|
Loading…
Reference in a new issue