Merge pull request #3801 from betagouv/fix_mail_notification
Email notification: use the right method for procedures
This commit is contained in:
commit
7face5e971
3 changed files with 7 additions and 5 deletions
|
@ -127,6 +127,8 @@ class Gestionnaire < ApplicationRecord
|
||||||
procedure.dossiers.termine
|
procedure.dossiers.termine
|
||||||
when :not_archived
|
when :not_archived
|
||||||
procedure.dossiers.not_archived
|
procedure.dossiers.not_archived
|
||||||
|
when :all
|
||||||
|
procedure.dossiers
|
||||||
else
|
else
|
||||||
procedure.dossiers.en_cours
|
procedure.dossiers.en_cours
|
||||||
end
|
end
|
||||||
|
@ -226,7 +228,7 @@ class Gestionnaire < ApplicationRecord
|
||||||
|
|
||||||
h = {
|
h = {
|
||||||
nb_en_construction: procedure.dossiers.en_construction.count,
|
nb_en_construction: procedure.dossiers.en_construction.count,
|
||||||
nb_notification: notifications_per_procedure(procedure).count
|
nb_notification: notifications_for_procedure(procedure, :all).count
|
||||||
}
|
}
|
||||||
|
|
||||||
if h[:nb_en_construction] > 0 || h[:nb_notification] > 0
|
if h[:nb_en_construction] > 0 || h[:nb_notification] > 0
|
||||||
|
|
|
@ -279,7 +279,7 @@ describe Gestionnaire, type: :model do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#notification_for_procedure' do
|
describe '#notifications_for_procedure' do
|
||||||
let!(:dossier) { create(:dossier, :followed, state: Dossier.states.fetch(:en_construction)) }
|
let!(:dossier) { create(:dossier, :followed, state: Dossier.states.fetch(:en_construction)) }
|
||||||
let(:gestionnaire) { dossier.follows.first.gestionnaire }
|
let(:gestionnaire) { dossier.follows.first.gestionnaire }
|
||||||
let(:procedure) { dossier.procedure }
|
let(:procedure) { dossier.procedure }
|
||||||
|
@ -438,8 +438,8 @@ describe Gestionnaire, type: :model do
|
||||||
|
|
||||||
context 'when a notification exists' do
|
context 'when a notification exists' do
|
||||||
before do
|
before do
|
||||||
allow(gestionnaire).to receive(:notifications_per_procedure)
|
allow(gestionnaire).to receive(:notifications_for_procedure)
|
||||||
.with(procedure_to_assign)
|
.with(procedure_to_assign, :all)
|
||||||
.and_return([1, 2, 3])
|
.and_return([1, 2, 3])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ describe NotificationService do
|
||||||
|
|
||||||
context 'when there is a notification on this procedure' do
|
context 'when there is a notification on this procedure' do
|
||||||
before do
|
before do
|
||||||
allow_any_instance_of(Gestionnaire).to receive(:notifications_per_procedure)
|
allow_any_instance_of(Gestionnaire).to receive(:notifications_for_procedure)
|
||||||
.and_return([12])
|
.and_return([12])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue