Get gestionnaire unread notifications for his follows files

This commit is contained in:
Xavier J 2016-12-27 10:57:21 +01:00
parent ce5bf8d622
commit 2e13cb6818
4 changed files with 9 additions and 9 deletions

View file

@ -27,11 +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, unread_notifications: @current_devise_profil.unread_notifications(procedure)}) }
@current_devise_profil.procedures.order('libelle ASC').inject([]) { |acc, procedure| acc.push({id: procedure.id, libelle: procedure.libelle, unread_notifications: @current_devise_profil.notifications_for(procedure)}) }
end
def unread_notifications
Notification.all
current_devise_profil.notifications
end
def procedure_id

View file

@ -63,7 +63,11 @@ class Gestionnaire < ActiveRecord::Base
PreferenceSmartListingPage.create(page: 1, procedure: nil, gestionnaire: self, liste: 'a_traiter')
end
def unread_notifications procedure
def notifications
Notification.where(already_read: false, dossier_id: follows.pluck(:dossier_id) )
end
def notifications_for procedure
procedure_ids = dossiers_follow.pluck(:procedure_id)
if procedure_ids.include?(procedure.id)

View file

@ -133,8 +133,4 @@ 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 '#unread_notifications' do
subject { gestionnaire.unread_notifications procedure }
describe '#notifications_for' do
subject { gestionnaire.notifications_for procedure }
context 'when gestionnaire follow any dossier' do
it { is_expected.to eq 0 }