fix #245 it should only count dossiers with notifications on followed dossiers
This commit is contained in:
parent
cfba1af7a4
commit
e5ac555a41
2 changed files with 33 additions and 1 deletions
|
@ -28,7 +28,7 @@
|
||||||
- if total_new > 0
|
- if total_new > 0
|
||||||
.badge.progress-bar-success{ title: 'Nouveaux dossiers' }
|
.badge.progress-bar-success{ title: 'Nouveaux dossiers' }
|
||||||
= total_new
|
= total_new
|
||||||
- unread_notif_count = procedure.notifications.unread.count
|
- unread_notif_count = current_gestionnaire.dossier_with_notification_for(procedure)
|
||||||
- if unread_notif_count > 0
|
- if unread_notif_count > 0
|
||||||
.badge.progress-bar-warning{ title: 'Notifications' }
|
.badge.progress-bar-warning{ title: 'Notifications' }
|
||||||
= unread_notif_count
|
= unread_notif_count
|
||||||
|
|
|
@ -312,4 +312,36 @@ describe Gestionnaire, type: :model do
|
||||||
it { is_expected.to eq(2) }
|
it { is_expected.to eq(2) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#dossier_with_notification_for' do
|
||||||
|
subject { gestionnaire.dossier_with_notification_for(procedure) }
|
||||||
|
|
||||||
|
context 'without notifications' do
|
||||||
|
it { is_expected.to eq(0) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with a followed dossier' do
|
||||||
|
let!(:dossier){create(:dossier, procedure: procedure, state: 'received')}
|
||||||
|
let!(:follow){ create(:follow, dossier: dossier, gestionnaire: gestionnaire) }
|
||||||
|
|
||||||
|
context 'with 1 notification' do
|
||||||
|
let!(:notification){ create(:notification, already_read: false, dossier: dossier) }
|
||||||
|
|
||||||
|
it { is_expected.to eq(1) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with 1 read notification' do
|
||||||
|
let!(:notification){ create(:notification, already_read: true, dossier: dossier) }
|
||||||
|
|
||||||
|
it { is_expected.to eq(0) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with 2 notification' do
|
||||||
|
let!(:notification){ create(:notification, already_read: false, dossier: dossier) }
|
||||||
|
let!(:notification2){ create(:notification, already_read: false, dossier: dossier) }
|
||||||
|
|
||||||
|
it { is_expected.to eq(1) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue