Merge pull request #1062 from sgmap/fix-1016

Fix 1016 : Notifications dans les onglets
This commit is contained in:
Mathieu Magnin 2017-12-14 14:14:51 +01:00 committed by GitHub
commit 22d77b5ab4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 270 additions and 61 deletions

View file

@ -1,7 +1,23 @@
TPS.scrollMessagerie = function () {
var scrollTo = function ($container, $scrollTo) {
$container.scrollTop(
$scrollTo.offset().top - $container.offset().top + $container.scrollTop()
);
}
var scrollToBottom = function ($container) {
$container.scrollTop($container.prop('scrollHeight'));
}
var $ul = $(".messagerie ul").first();
if($ul.length) {
$ul.scrollTop($ul.prop('scrollHeight'));
var $elementToScroll = $('.date.highlighted').first();
if ($elementToScroll.length != 0) {
scrollTo($ul, $elementToScroll);
} else {
scrollToBottom($ul);
}
}
};

View file

@ -12,3 +12,4 @@ $lighter-green: lighten($green, 30%);
$light-green: lighten($green, 25%);
$dark-green: darken($green, 20%);
$orange: #F59415;
$orange-bg: lighten($orange, 35%);

View file

@ -1,6 +1,7 @@
@import "colors";
@import "constants";
.dossier-champs {
.table.dossier-champs {
th,
td {
vertical-align: top;
@ -9,4 +10,23 @@
.libelle {
width: 250px;
}
td.updated-at {
font-size: 13px;
color: $grey;
text-align: right;
width: 190px;
> span {
opacity: 0;
&.highlighted {
opacity: 1;
}
}
}
tr:hover .updated-at > span {
opacity: 1;
}
}

View file

@ -7,6 +7,11 @@
margin-bottom: 20px;
}
@mixin notice-text-style {
font-size: 14px;
color: $grey;
}
label {
margin-bottom: $default-padding;
display: block;
@ -16,10 +21,24 @@
}
.notice {
font-size: 14px;
@include notice-text-style;
display: block;
margin-top: $default-spacer;
color: $grey;
}
}
.champ {
.updated-at {
@include notice-text-style;
float: right;
display: inline-block;
margin-left: $default-spacer;
visibility: hidden;
}
&:hover .updated-at,
.updated-at.highlighted {
visibility: visible;
}
}

View file

@ -1,3 +1,5 @@
@import "colors";
.pull-left {
float: left;
}
@ -32,3 +34,8 @@
text-align: center;
margin: 60px 0;
}
.highlighted {
background: $orange-bg;
color: $black;
}

View file

@ -3,29 +3,30 @@ module NewGestionnaire
include ActionView::Helpers::NumberHelper
include ActionView::Helpers::TextHelper
after_action :mark_demande_as_read, only: :show
after_action :mark_messagerie_as_read, only: [:messagerie, :create_commentaire]
after_action :mark_avis_as_read, only: [:avis, :create_avis]
after_action :mark_annotations_privees_as_read, only: [:annotations_privees, :update_annotations]
def attestation
send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf')
end
def show
dossier.notifications.demande.mark_as_read
current_gestionnaire.mark_tab_as_seen(dossier, :demande)
@demande_seen_at = current_gestionnaire.follows.find_by(dossier: dossier)&.demande_seen_at
end
def messagerie
dossier.notifications.messagerie.mark_as_read
current_gestionnaire.mark_tab_as_seen(dossier, :messagerie)
@commentaire = Commentaire.new
@messagerie_seen_at = current_gestionnaire.follows.find_by(dossier: dossier)&.messagerie_seen_at
end
def annotations_privees
dossier.notifications.annotations_privees.mark_as_read
current_gestionnaire.mark_tab_as_seen(dossier, :annotations_privees)
@annotations_privees_seen_at = current_gestionnaire.follows.find_by(dossier: dossier)&.annotations_privees_seen_at
end
def avis
dossier.notifications.avis.mark_as_read
current_gestionnaire.mark_tab_as_seen(dossier, :avis)
@avis_seen_at = current_gestionnaire.follows.find_by(dossier: dossier)&.avis_seen_at
end
def personnes_impliquees
@ -192,5 +193,25 @@ module NewGestionnaire
dossier&.attestation&.emailable?
end
def mark_demande_as_read
dossier.notifications.demande.mark_as_read
current_gestionnaire.mark_tab_as_seen(dossier, :demande)
end
def mark_messagerie_as_read
dossier.notifications.messagerie.mark_as_read
current_gestionnaire.mark_tab_as_seen(dossier, :messagerie)
end
def mark_avis_as_read
dossier.notifications.avis.mark_as_read
current_gestionnaire.mark_tab_as_seen(dossier, :avis)
end
def mark_annotations_privees_as_read
dossier.notifications.annotations_privees.mark_as_read
current_gestionnaire.mark_tab_as_seen(dossier, :annotations_privees)
end
end
end

View file

@ -8,4 +8,10 @@ module DossierHelper
'refused'
end
end
def highlight_if_unseen_class(seen_at, updated_at)
if seen_at&.<(updated_at)
"highlighted"
end
end
end

View file

@ -9,9 +9,9 @@ class Follow < ActiveRecord::Base
private
def set_default_date
self.demande_seen_at = DateTime.now
self.annotations_privees_seen_at = DateTime.now
self.avis_seen_at = DateTime.now
self.messagerie_seen_at = DateTime.now
self.demande_seen_at ||= DateTime.now
self.annotations_privees_seen_at ||= DateTime.now
self.avis_seen_at ||= DateTime.now
self.messagerie_seen_at ||= DateTime.now
end
end

View file

@ -15,7 +15,8 @@
%span.confidentiel
confidentiel
%span.icon.lock{ title: "Cet avis n'est pas affiché avec les autres experts consultés" }
%span.date Demande d'avis envoyée le #{I18n.l(avis.created_at.localtime, format: '%d/%m/%y')}
%span.date{ class: highlight_if_unseen_class(avis_seen_at, avis.created_at) }
Demande d'avis envoyée le #{I18n.l(avis.created_at.localtime, format: '%d/%m/%y à %H:%M')}
%p= avis.introduction
.answer.flex.align-start
@ -24,7 +25,8 @@
%h2.gestionnaire
= (avis.email_to_display == current_gestionnaire.email) ? 'Vous' : avis.email_to_display
- if avis.answer.present?
%span.date Réponse donnée le #{I18n.l(avis.updated_at.localtime, format: '%d/%m/%y')}
%span.date{ class: highlight_if_unseen_class(avis_seen_at, avis.updated_at) }
Réponse donnée le #{I18n.l(avis.updated_at.localtime, format: '%d/%m/%y à %H:%M')}
- else
%span.waiting En attente de réponse
%p= avis.answer

View file

@ -42,4 +42,4 @@
.send-wrapper
= f.submit 'Demander un avis', class: 'button send'
= render partial: 'avis_list', locals: { avis: @dossier.avis_for(current_gestionnaire) }
= render partial: 'avis_list', locals: { avis: @dossier.avis_for(current_gestionnaire), avis_seen_at: nil }

View file

@ -6,6 +6,6 @@
%ul.messages-list
- @dossier.commentaires.each do |commentaire|
%li
= render partial: "new_gestionnaire/shared/commentaires/commentaire", locals: { commentaire: commentaire }
= render partial: "new_gestionnaire/shared/commentaires/commentaire", locals: { commentaire: commentaire, messagerie_seen_at: nil }
= render partial: "new_gestionnaire/shared/commentaires/form", locals: { commentaire: @commentaire, form_url: commentaire_avis_path(@avis) }

View file

@ -16,7 +16,7 @@
- champs = @dossier.ordered_champs.decorate
- if champs.any?
.card
= render partial: 'new_gestionnaire/dossiers/champs', locals: { champs: champs }
= render partial: 'new_gestionnaire/dossiers/champs', locals: { champs: champs, dossier: @dossier, demande_seen_at: nil }
- if @dossier.procedure.use_api_carto
.accompagnateur-title Cartographie
@ -26,4 +26,4 @@
- if @dossier.procedure.cerfa_flag? || @dossier.types_de_piece_justificative.any?
.accompagnateur-title Pièces jointes
.card
= render partial: "new_gestionnaire/dossiers/pieces_jointes", locals: { dossier: @dossier }
= render partial: "new_gestionnaire/dossiers/pieces_jointes", locals: { dossier: @dossier, demande_seen_at: nil }

View file

@ -4,7 +4,7 @@
%tr
- case c.type_champ
- when "header_section"
%th.header-section{ colspan: 2 }
%th.header-section{ colspan: 3 }
= c.libelle
- when "multiple_drop_down_list"
%th.libelle
@ -34,4 +34,10 @@
%th.libelle
= "#{c.libelle} :"
%td.rich-text
= sanitize(c.value)
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
= sanitize(c.value)
- if c.type_champ != "header_section"
%td.updated-at
%span{ class: highlight_if_unseen_class(demande_seen_at, c.updated_at) }
modifié le
= c.updated_at.localtime.strftime("%d/%m/%Y à %H:%M")

View file

@ -1,4 +1,4 @@
%table.table.vertical.pj
%table.table.vertical.pj.dossier-champs
%tbody
- if dossier.procedure.cerfa_flag?
%tr
@ -8,17 +8,22 @@
= link_to "Télécharger", @dossier.cerfa.last.content_url, class: "link", target: :blank
- else
Pièce non fournie
%td
- dossier.procedure.types_de_piece_justificative.each do |type_de_piece_justificative|
- pjs = dossier.retrieve_all_piece_justificative_by_type(type_de_piece_justificative.id).to_ary.dup
- pj = pjs.shift if pjs.present?
%tr
%th= "#{type_de_piece_justificative.libelle} :"
- pjs = dossier.retrieve_all_piece_justificative_by_type(type_de_piece_justificative.id).to_ary.dup
- if pjs.present?
- first_pj = pjs.pop
%td= display_pj_filename(first_pj)
%td= link_to "Télécharger", first_pj.content_url, class: "link", target: :blank
- if pj
%td
%span{ class: highlight_if_unseen_class(demande_seen_at, pj.updated_at) }
= display_pj_filename(pj)
·
= link_to "Télécharger", pj.content_url, class: "link", target: :blank
- if pjs.present?
%br
%span.button.dropdown
anciennes versions
.dropdown-content.fade-in-down
@ -28,6 +33,11 @@
= link_to pj.content_url, { target: :blank } do
%span.filename= display_pj_filename(pj)
%span
ajoutée le #{pj.created_at.localtime.strftime('%d/%m %H:%M')}
ajoutée le #{pj.created_at.localtime.strftime('%d/%m/%Y à %H:%M')}
- else
%td Pièce non fournie
%td.updated-at
- if pj
%span{ class: highlight_if_unseen_class(demande_seen_at, pj.updated_at) }
modifié le
= pj.updated_at.localtime.strftime("%d/%m/%Y à %H:%M")

View file

@ -10,8 +10,8 @@
= form_for @dossier, url: annotations_dossier_path(@dossier.procedure, @dossier), html: { class: 'form' } do |f|
= f.fields_for :champs_private, f.object.ordered_champs_private do |champ_form|
- champ = champ_form.object
= render partial: "new_gestionnaire/dossiers/champs/#{champ.type_champ}",
locals: { champ: champ, form: champ_form }
= render partial: "new_gestionnaire/dossiers/champs/champ",
locals: { champ: champ, form: champ_form, seen_at: @annotations_privees_seen_at }
.send-wrapper
= f.submit 'Sauvegarder', class: 'button send', data: { disable_with: "Envoi..." }

View file

@ -17,4 +17,4 @@
.send-wrapper
= f.submit 'Demander un avis', class: 'button send', data: { disable_with: "Envoi..." }
= render partial: 'new_gestionnaire/avis/avis_list', locals: { avis: @dossier.avis }
= render partial: 'new_gestionnaire/avis/avis_list', locals: { avis: @dossier.avis, avis_seen_at: @avis_seen_at }

View file

@ -1,4 +1,4 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ }
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.text_field :value,
'data-address': 'true',

View file

@ -0,0 +1,3 @@
.champ
= render partial: "new_gestionnaire/dossiers/champs/#{champ.type_champ}",
locals: { champ: champ, form: form, seen_at: seen_at }

View file

@ -2,5 +2,10 @@
#{champ.libelle}
- if champ.mandatory
%span.mandatory *
- if champ.updated_at.present?
%span.updated-at{ class: highlight_if_unseen_class(seen_at, champ.updated_at) }
= "modifié le #{champ.updated_at.strftime('%d/%m/%Y à %H:%M')}"
- if champ.description.present?
%span.notice= champ.description

View file

@ -1,4 +1,4 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ }
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.check_box :value,
{ required: champ.mandatory },

View file

@ -1,4 +1,4 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ }
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
.radios
%label

View file

@ -1,4 +1,4 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ }
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.date_field :value,
value: champ.value,

View file

@ -1,4 +1,4 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ }
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
- parsed_value = champ.value.present? ? DateTime.parse(champ.value) : DateTime.now

View file

@ -1,4 +1,4 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ }
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.select :value,
Champ.departements,

View file

@ -1,4 +1,4 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ }
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
- dossier = Dossier.find_by(id: champ.value)
- show_text_summary = dossier.present?

View file

@ -1,4 +1,4 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ }
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
- if champ.drop_down_list && champ.drop_down_list.options.any?
= form.select :value,

View file

@ -1,4 +1,4 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ }
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.email_field :value,
placeholder: champ.libelle,

View file

@ -1,4 +1,4 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ }
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.check_box :value,
{ required: champ.mandatory },

View file

@ -1,4 +1,4 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ }
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
- if champ.drop_down_list && champ.drop_down_list.options.any?
= form.select :value,

View file

@ -1,4 +1,4 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ }
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.number_field :value,
placeholder: champ.libelle,

View file

@ -1,4 +1,4 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ }
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.select :value,
Champ.pays,

View file

@ -1,4 +1,4 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ }
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.phone_field :value,
placeholder: champ.libelle,

View file

@ -1,4 +1,4 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ }
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.select :value,
Champ.regions,

View file

@ -1,4 +1,4 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ }
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
= form.text_field :value,
placeholder: champ.libelle,

View file

@ -1,4 +1,4 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ }
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
~ form.text_area :value,
row: 6,

View file

@ -1,4 +1,4 @@
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ }
= render partial: 'new_gestionnaire/dossiers/champs/champ_label', locals: { form: form, champ: champ, seen_at: seen_at }
.radios
%label

View file

@ -6,6 +6,6 @@
%ul.messages-list
- @dossier.commentaires.each do |commentaire|
%li
= render partial: "new_gestionnaire/shared/commentaires/commentaire", locals: { commentaire: commentaire }
= render partial: "new_gestionnaire/shared/commentaires/commentaire", locals: { commentaire: commentaire, messagerie_seen_at: @messagerie_seen_at }
= render partial: "new_gestionnaire/shared/commentaires/form", locals: { commentaire: @commentaire, form_url: commentaire_dossier_path(@dossier.procedure, @dossier) }

View file

@ -13,7 +13,7 @@
- champs = @dossier.ordered_champs.decorate
- if champs.any?
= render partial: "champs", locals: { champs: champs }
= render partial: "champs", locals: { champs: champs, dossier: @dossier }
- if @dossier.procedure.use_api_carto
%h3 Cartographie

View file

@ -15,7 +15,7 @@
- champs = @dossier.ordered_champs.includes(:type_de_champ).decorate
- if champs.any?
.card
= render partial: "champs", locals: { champs: champs }
= render partial: "champs", locals: { champs: champs, dossier: @dossier, demande_seen_at: @demande_seen_at }
- if @dossier.procedure.use_api_carto
.accompagnateur-title Cartographie
@ -25,4 +25,4 @@
- if @dossier.procedure.cerfa_flag? || @dossier.types_de_piece_justificative.any?
.accompagnateur-title Pièces jointes
.card
= render partial: "pieces_jointes", locals: { dossier: @dossier }
= render partial: "pieces_jointes", locals: { dossier: @dossier, demande_seen_at: @demande_seen_at }

View file

@ -4,9 +4,10 @@
%h2
%span.mail
= render partial: 'new_gestionnaire/shared/commentaires/commentaire_issuer', locals: { commentaire: commentaire, current_gestionnaire: current_gestionnaire }
- if ![current_gestionnaire.email, @dossier.user.email, 'contact@tps.apientreprise.fr'].include?(commentaire.email)
- if ![current_gestionnaire.email, commentaire.dossier.user.email, 'contact@tps.apientreprise.fr'].include?(commentaire.email)
%span.guest Invité
%span.date= I18n.l(commentaire.created_at.localtime, format: '%H:%M le %d/%m/%Y')
%span.date{ class: highlight_if_unseen_class(messagerie_seen_at, commentaire.created_at) }
= I18n.l(commentaire.created_at.localtime, format: '%d/%m/%Y à %H:%M ')
.rich-text= sanitize(commentaire.body)
- if commentaire.piece_justificative

View file

@ -23,8 +23,8 @@
= form_for @dossier, url: '', html: { class: 'form' } do |f|
= f.fields_for :champs do |champ_form|
- champ = champ_form.object
= render partial: "new_gestionnaire/dossiers/champs/#{champ.type_champ}",
locals: { champ: champ, form: champ_form }
= render partial: "new_gestionnaire/dossiers/champs/champ",
locals: { champ: champ, form: champ_form, seen_at: nil }
%input{ type: "password", value: "12345678" }
.send-wrapper

View file

@ -0,0 +1,28 @@
require 'rails_helper'
RSpec.describe DossierHelper, type: :helper do
describe ".highlight_if_unseen_class" do
let(:seen_at) { DateTime.now }
subject { highlight_if_unseen_class(seen_at, updated_at) }
context "when commentaire date is created before last seen datetime" do
let(:updated_at) { seen_at - 2.days }
it { is_expected.to eq nil }
end
context "when commentaire date is created after last seen datetime" do
let(:updated_at) { seen_at + 2.hours }
it { is_expected.to eq "highlighted" }
end
context "when there is no last seen datetime" do
let(:updated_at) { DateTime.now }
let(:seen_at) { nil }
it { is_expected.to eq nil }
end
end
end

View file

@ -0,0 +1,20 @@
describe 'new_gestionnaire/avis/avis_list.html.haml', type: :view do
before { view.extend DossierHelper }
subject { render 'new_gestionnaire/avis/avis_list.html.haml', avis: avis, avis_seen_at: seen_at, current_gestionnaire: gestionnaire }
let(:gestionnaire) { create(:gestionnaire) }
let(:avis) { [create(:avis, claimant: gestionnaire)] }
context "with a seen_at after avis created_at" do
let(:seen_at) { avis.first.created_at + 1.hour }
it { is_expected.not_to have_css(".highlighted") }
end
context "with a seen_at after avis created_at" do
let(:seen_at) { avis.first.created_at - 1.hour }
it { is_expected.to have_css(".highlighted") }
end
end

View file

@ -1,12 +1,14 @@
describe 'new_gestionnaire/dossiers/champs.html.haml', type: :view do
let(:gestionnaire) { create(:gestionnaire) }
let(:demande_seen_at) { nil }
before do
view.extend DossierHelper
view.extend DossierLinkHelper
allow(view).to receive(:current_gestionnaire).and_return(gestionnaire)
end
subject { render 'new_gestionnaire/dossiers/champs.html.haml', champs: champs }
subject { render 'new_gestionnaire/dossiers/champs.html.haml', champs: champs, demande_seen_at: demande_seen_at }
context "there are some champs" do
let(:dossier) { create(:dossier) }
@ -48,4 +50,22 @@ describe 'new_gestionnaire/dossiers/champs.html.haml', type: :view do
it { is_expected.to include("Pas de dossier associé") }
end
context "with seen_at" do
let(:dossier) { create(:dossier) }
let(:champ1) { create(:champ, :checkbox, value: "true") }
let(:champs) { [champ1] }
context "with a demande_seen_at after champ updated_at" do
let(:demande_seen_at) { champ1.updated_at + 1.hour }
it { is_expected.not_to have_css(".highlighted") }
end
context "with a demande_seen_at after champ updated_at" do
let(:demande_seen_at) { champ1.updated_at - 1.hour }
it { is_expected.to have_css(".highlighted") }
end
end
end

View file

@ -1,4 +1,6 @@
describe 'new_gestionnaire/dossiers/show.html.haml', type: :view do
before { view.extend DossierHelper }
let(:current_gestionnaire) { create(:gestionnaire) }
let(:individual) { nil }
let(:entreprise) { nil }

View file

@ -0,0 +1,22 @@
describe 'new_gestionnaire/shared/commentaires/commentaire.html.haml', type: :view do
before { view.extend DossierHelper }
subject { render 'new_gestionnaire/shared/commentaires/commentaire.html.haml', commentaire: commentaire, messagerie_seen_at: seen_at, current_gestionnaire: current_gestionnaire }
let(:dossier) { create(:dossier) }
let(:commentaire) { create(:commentaire, dossier: dossier) }
let(:current_gestionnaire) { create(:gestionnaire) }
let(:seen_at) { commentaire.created_at + 1.hour }
context "with a seen_at after commentaire created_at" do
let(:seen_at) { commentaire.created_at + 1.hour }
it { is_expected.not_to have_css(".highlighted") }
end
context "with a seen_at after commentaire created_at" do
let(:seen_at) { commentaire.created_at - 1.hour }
it { is_expected.to have_css(".highlighted") }
end
end