[Fix #763] Add annotations_privees to buggy annotation system
This commit is contained in:
parent
f2e1480c73
commit
2b760c85c4
6 changed files with 29 additions and 10 deletions
|
@ -16,6 +16,7 @@ module NewGestionnaire
|
|||
|
||||
def annotations_privees
|
||||
@dossier = dossier
|
||||
dossier.notifications.annotations_privees.mark_as_read
|
||||
end
|
||||
|
||||
def avis
|
||||
|
|
|
@ -83,8 +83,12 @@ class Champ < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def internal_notification
|
||||
unless dossier.state == 'draft'
|
||||
NotificationService.new('champs', self.dossier.id, self.libelle).notify
|
||||
if dossier.state != 'draft'
|
||||
if type == 'ChampPublic'
|
||||
NotificationService.new('champs', self.dossier.id, self.libelle).notify
|
||||
else
|
||||
NotificationService.new('annotations_privees', self.dossier.id, self.libelle).notify
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -97,7 +97,8 @@ class Dossier < ActiveRecord::Base
|
|||
{
|
||||
demande: unread_notifications.select(&:demande?).present?,
|
||||
avis: unread_notifications.select(&:avis?).present?,
|
||||
messagerie: unread_notifications.select(&:messagerie?).present?
|
||||
messagerie: unread_notifications.select(&:messagerie?).present?,
|
||||
annotations_privees: unread_notifications.select(&:annotations_privees?).present?
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ class Notification < ActiveRecord::Base
|
|||
DEMANDE = %w(cerfa piece_justificative champs submitted)
|
||||
AVIS = %w(avis)
|
||||
MESSAGERIE = %w(commentaire)
|
||||
ANNOTATIONS_PRIVEES = %w(annotations_privees)
|
||||
|
||||
belongs_to :dossier
|
||||
|
||||
|
@ -19,7 +20,7 @@ class Notification < ActiveRecord::Base
|
|||
scope :demande, -> { where(type_notif: DEMANDE) }
|
||||
scope :avis, -> { where(type_notif: AVIS) }
|
||||
scope :messagerie, -> { where(type_notif: MESSAGERIE) }
|
||||
scope :annotations_privees, -> { where(type_notif: annotations_privees) }
|
||||
scope :annotations_privees, -> { where(type_notif: ANNOTATIONS_PRIVEES) }
|
||||
scope :mark_as_read, -> { update_all(already_read: true) }
|
||||
|
||||
def demande?
|
||||
|
@ -33,4 +34,8 @@ class Notification < ActiveRecord::Base
|
|||
def messagerie?
|
||||
Notification::MESSAGERIE.include?(type_notif)
|
||||
end
|
||||
|
||||
def annotations_privees?
|
||||
Notification::ANNOTATIONS_PRIVEES.include?(type_notif)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
%span.notifications{ 'aria-label': 'notifications' }
|
||||
= link_to "Demande", dossier_path(dossier.procedure, dossier)
|
||||
%li{ class: current_page?(annotations_privees_dossier_path(dossier.procedure, dossier)) ? 'active' : nil }
|
||||
- if notifications_summary[:annotations_privees]
|
||||
%span.notifications{ 'aria-label': 'notifications' }
|
||||
= link_to "Annotations Privées", annotations_privees_dossier_path(dossier.procedure, dossier)
|
||||
%li{ class: current_page?(avis_dossier_path(dossier.procedure, dossier)) ? 'active' : nil }
|
||||
- if notifications_summary[:avis]
|
||||
|
|
|
@ -74,28 +74,34 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
it { expect(response).to redirect_to(procedures_url) }
|
||||
end
|
||||
|
||||
describe '#show #messagerie #instruction' do
|
||||
describe '#show #messagerie #annotations_privees #avis' do
|
||||
before do
|
||||
dossier.notifications = %w(champs avis commentaire).map{ |type| Notification.create!(type_notif: type) }
|
||||
dossier.notifications = %w(champs annotations_privees avis commentaire).map{ |type| Notification.create!(type_notif: type) }
|
||||
get method, params: { procedure_id: procedure.id, dossier_id: dossier.id }
|
||||
dossier.notifications.each(&:reload)
|
||||
end
|
||||
|
||||
context '#show' do
|
||||
let(:method) { :show }
|
||||
it { expect(dossier.notifications.map(&:already_read)).to match([true, false, false]) }
|
||||
it { expect(dossier.notifications.map(&:already_read)).to match([true, false, false, false]) }
|
||||
it { expect(response).to have_http_status(:success) }
|
||||
end
|
||||
|
||||
context '#instruction' do
|
||||
context '#annotations_privees' do
|
||||
let(:method) { :annotations_privees }
|
||||
it { expect(dossier.notifications.map(&:already_read)).to match([false, true, false]) }
|
||||
it { expect(dossier.notifications.map(&:already_read)).to match([false, true, false, false]) }
|
||||
it { expect(response).to have_http_status(:success) }
|
||||
end
|
||||
|
||||
context '#avis' do
|
||||
let(:method) { :avis }
|
||||
it { expect(dossier.notifications.map(&:already_read)).to match([false, false, true, false]) }
|
||||
it { expect(response).to have_http_status(:success) }
|
||||
end
|
||||
|
||||
context '#messagerie' do
|
||||
let(:method) { :messagerie }
|
||||
it { expect(dossier.notifications.map(&:already_read)).to match([false, false, true]) }
|
||||
it { expect(dossier.notifications.map(&:already_read)).to match([false, false, false, true]) }
|
||||
it { expect(response).to have_http_status(:success) }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue