diff --git a/app/facades/dossiers_list_facades.rb b/app/facades/dossiers_list_facades.rb index 62e235748..7fd490661 100644 --- a/app/facades/dossiers_list_facades.rb +++ b/app/facades/dossiers_list_facades.rb @@ -27,7 +27,11 @@ class DossiersListFacades end def gestionnaire_procedures_name_and_id_list - @current_devise_profil.procedures.order('libelle ASC').inject([]) { |acc, procedure| acc.push({id: procedure.id, libelle: procedure.libelle, notification_unread: @current_devise_profil.notification_unread(procedure)}) } + @current_devise_profil.procedures.order('libelle ASC').inject([]) { |acc, procedure| acc.push({id: procedure.id, libelle: procedure.libelle, unread_notifications: @current_devise_profil.unread_notifications(procedure)}) } + end + + def unread_notifications + Notification.all end def procedure_id diff --git a/app/models/gestionnaire.rb b/app/models/gestionnaire.rb index 0a89eee03..8a840f5db 100644 --- a/app/models/gestionnaire.rb +++ b/app/models/gestionnaire.rb @@ -63,7 +63,7 @@ class Gestionnaire < ActiveRecord::Base PreferenceSmartListingPage.create(page: 1, procedure: nil, gestionnaire: self, liste: 'a_traiter') end - def notification_unread procedure + def unread_notifications procedure procedure_ids = dossiers_follow.pluck(:procedure_id) if procedure_ids.include?(procedure.id) diff --git a/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_index.html.haml b/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_index.html.haml index bee85d9c5..141d14e0b 100644 --- a/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_index.html.haml +++ b/app/views/layouts/left_panels/_left_panel_backoffice_dossierscontroller_index.html.haml @@ -17,6 +17,6 @@ = link_to backoffice_dossiers_procedure_path(procedure[:id]), {title: procedure[:libelle]} do %div.procedure_list_element{ class: ('active' if procedure[:id] == @facade_data_view.procedure.id rescue '') } = truncate(procedure[:libelle], length: 50) - -if procedure[:notification_unread] > 0 + -if procedure[:unread_notifications] > 0 .badge.progress-bar-warning - = procedure[:notification_unread] + = procedure[:unread_notifications] diff --git a/spec/facades/dossiers_list_facades_spec.rb b/spec/facades/dossiers_list_facades_spec.rb index cc8eeb4be..c0c618d7e 100644 --- a/spec/facades/dossiers_list_facades_spec.rb +++ b/spec/facades/dossiers_list_facades_spec.rb @@ -50,12 +50,12 @@ describe DossiersListFacades do it { expect(subject.first[:id]).to eq procedure.id } it { expect(subject.first[:libelle]).to eq procedure.libelle } - it { expect(subject.first[:notification_unread]).to eq 0 } + it { expect(subject.first[:unread_notifications]).to eq 0 } it { expect(subject.last[:id]).to eq procedure_2.id } it { expect(subject.last[:libelle]).to eq procedure_2.libelle } - it { expect(subject.last[:notification_unread]).to eq 0 } + it { expect(subject.last[:unread_notifications]).to eq 0 } end describe '#active_filter?' do @@ -133,4 +133,8 @@ describe DossiersListFacades do end end end + + describe 'unread_notifications' do + pending + end end \ No newline at end of file diff --git a/spec/models/gestionnaire_spec.rb b/spec/models/gestionnaire_spec.rb index 572240d48..d16d4df2e 100644 --- a/spec/models/gestionnaire_spec.rb +++ b/spec/models/gestionnaire_spec.rb @@ -209,8 +209,8 @@ describe Gestionnaire, type: :model do end end - describe '#notification_unread' do - subject { gestionnaire.notification_unread procedure } + describe '#unread_notifications' do + subject { gestionnaire.unread_notifications procedure } context 'when gestionnaire follow any dossier' do it { is_expected.to eq 0 }