messagerie: fix 'Invité' label in message sender
This commit is contained in:
parent
211674435e
commit
353ab812fc
3 changed files with 22 additions and 1 deletions
|
@ -5,6 +5,10 @@ module CommentaireHelper
|
|||
end
|
||||
end
|
||||
|
||||
def commentaire_is_from_guest(commentaire)
|
||||
commentaire.dossier.invites.map(&:email).include?(commentaire.email)
|
||||
end
|
||||
|
||||
def commentaire_date(commentaire)
|
||||
is_current_year = (commentaire.created_at.year == Date.current.year)
|
||||
template = is_current_year ? :message_date : :message_date_with_year
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
%h2
|
||||
%span.mail
|
||||
= render partial: 'shared/dossiers/messages/message_issuer', locals: { commentaire: commentaire, user_email: user_email }
|
||||
- if ![user_email, commentaire.dossier.user.email, OLD_CONTACT_EMAIL, CONTACT_EMAIL].include?(commentaire.email)
|
||||
- if commentaire_is_from_guest(commentaire)
|
||||
%span.guest Invité
|
||||
%span.date{ class: highlight_if_unseen_class(messagerie_seen_at, commentaire.created_at) }
|
||||
= commentaire_date(commentaire)
|
||||
|
|
|
@ -19,6 +19,23 @@ RSpec.describe CommentaireHelper, type: :helper do
|
|||
end
|
||||
end
|
||||
|
||||
describe '.commentaire_is_from_guest' do
|
||||
let(:dossier) { create(:dossier) }
|
||||
let!(:guest) { create(:invite_user, dossier: dossier) }
|
||||
|
||||
subject { commentaire_is_from_guest(commentaire) }
|
||||
|
||||
context 'when the commentaire sender is not a guest' do
|
||||
let(:commentaire) { create(:commentaire, dossier: dossier, email: "michel@pref.fr") }
|
||||
it { is_expected.to be false }
|
||||
end
|
||||
|
||||
context 'when the commentaire sender is a guest on this dossier' do
|
||||
let(:commentaire) { create(:commentaire, dossier: dossier, email: guest.email) }
|
||||
it { is_expected.to be true }
|
||||
end
|
||||
end
|
||||
|
||||
describe '.commentaire_date' do
|
||||
let(:present_date) { Time.local(2018, 9, 2, 10, 5, 0) }
|
||||
let(:creation_date) { present_date }
|
||||
|
|
Loading…
Reference in a new issue