Initialize fonction « unread_notifications » in DossierListFacade

This commit is contained in:
Xavier J 2016-12-27 10:47:23 +01:00
parent 4e6adf5bc3
commit ce5bf8d622
5 changed files with 16 additions and 8 deletions

View file

@ -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

View file

@ -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)

View file

@ -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]

View file

@ -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

View file

@ -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 }