Display the full User
email in Commentaires
* Only redact gestionnaires’ emails * Also, rename Commentaire.sender to Commentaire.redacted_email
This commit is contained in:
parent
3bf19de124
commit
2abd93d360
3 changed files with 25 additions and 5 deletions
|
@ -25,12 +25,14 @@ class Commentaire < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def header
|
def header
|
||||||
"#{sender}, #{I18n.l(created_at, format: '%d %b %Y %H:%M')}"
|
"#{redacted_email}, #{I18n.l(created_at, format: '%d %b %Y %H:%M')}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def sender
|
def redacted_email
|
||||||
if email.present?
|
if gestionnaire.present?
|
||||||
email.split('@').first
|
gestionnaire.email.split('@').first
|
||||||
|
else
|
||||||
|
email
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,4 +5,4 @@
|
||||||
- when CONTACT_EMAIL
|
- when CONTACT_EMAIL
|
||||||
Email automatique
|
Email automatique
|
||||||
- else
|
- else
|
||||||
= commentaire.sender
|
= commentaire.redacted_email
|
||||||
|
|
|
@ -7,6 +7,24 @@ describe Commentaire do
|
||||||
it { is_expected.to have_db_column(:updated_at) }
|
it { is_expected.to have_db_column(:updated_at) }
|
||||||
it { is_expected.to belong_to(:dossier) }
|
it { is_expected.to belong_to(:dossier) }
|
||||||
|
|
||||||
|
describe "#redacted_email" do
|
||||||
|
subject { commentaire.redacted_email }
|
||||||
|
|
||||||
|
context 'with a commentaire created by a gestionnaire' do
|
||||||
|
let(:commentaire) { build :commentaire, gestionnaire: gestionnaire }
|
||||||
|
let(:gestionnaire) { build :gestionnaire, email: 'some_user@exemple.fr' }
|
||||||
|
|
||||||
|
it { is_expected.to eq 'some_user' }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with a commentaire created by a user' do
|
||||||
|
let(:commentaire) { build :commentaire, user: user }
|
||||||
|
let(:user) { build :user, email: 'some_user@exemple.fr' }
|
||||||
|
|
||||||
|
it { is_expected.to eq 'some_user@exemple.fr' }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "#notify" do
|
describe "#notify" do
|
||||||
let(:procedure) { create(:procedure) }
|
let(:procedure) { create(:procedure) }
|
||||||
let(:gestionnaire) { create(:gestionnaire) }
|
let(:gestionnaire) { create(:gestionnaire) }
|
||||||
|
|
Loading…
Reference in a new issue