update with_notifications dossiers scope (used in procedure index and show)

This commit is contained in:
simon lehericey 2021-10-04 10:05:27 +02:00
parent f662b28baf
commit 65911b7680
2 changed files with 14 additions and 2 deletions

View file

@ -364,6 +364,7 @@ class Dossier < ApplicationRecord
scope :with_notifications, -> do
joins(:follows)
.where('last_champ_updated_at > follows.demande_seen_at' \
' OR identity_updated_at > follows.demande_seen_at' \
' OR groupe_instructeur_updated_at > follows.demande_seen_at' \
' OR last_champ_private_updated_at > follows.annotations_privees_seen_at' \
' OR last_avis_updated_at > follows.avis_seen_at' \

View file

@ -257,9 +257,9 @@ describe Instructeur, type: :model do
describe '#notifications_for_groupe_instructeurs' do
# one procedure, one group, 2 instructeurs
let(:procedure) { create(:simple_procedure, :routee, :with_type_de_champ_private) }
let(:procedure) { create(:simple_procedure, :routee, :with_type_de_champ_private, :for_individual) }
let(:gi_p1) { procedure.groupe_instructeurs.last }
let!(:dossier) { create(:dossier, :followed, groupe_instructeur: gi_p1, state: Dossier.states.fetch(:en_construction)) }
let!(:dossier) { create(:dossier, :with_individual, :followed, groupe_instructeur: gi_p1, state: Dossier.states.fetch(:en_construction)) }
let(:instructeur) { dossier.follows.first.instructeur }
let!(:instructeur_2) { create(:instructeur, groupe_instructeurs: [gi_p1]) }
@ -339,6 +339,17 @@ describe Instructeur, type: :model do
it { is_expected.to match([dossier.id]) }
end
context 'the identity' do
context 'when there is a modification on the identity' do
before do
dossier.update!(identity_updated_at: Time.zone.now)
follow.update_attribute('demande_seen_at', seen_at_instructeur)
end
it { is_expected.to match([dossier.id]) }
end
end
context 'the messagerie' do
context 'when there is a new commentaire' do
before do