MailTemplate: add email and nom_organisation tag
This commit is contained in:
parent
6c560e65eb
commit
c8f515832b
2 changed files with 15 additions and 2 deletions
|
@ -13,6 +13,12 @@ class MailTemplate < ActiveRecord::Base
|
||||||
},
|
},
|
||||||
libelle_procedure: {
|
libelle_procedure: {
|
||||||
description: "Permet d'afficher le libellé de la procédure."
|
description: "Permet d'afficher le libellé de la procédure."
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
description: "Permet d'afficher l'email du porteur de projet."
|
||||||
|
},
|
||||||
|
nom_organisation: {
|
||||||
|
description: "Permet d'afficher le nom de l'organisation."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +40,10 @@ class MailTemplate < ActiveRecord::Base
|
||||||
|
|
||||||
def replace_tag tag, dossier
|
def replace_tag tag, dossier
|
||||||
case tag
|
case tag
|
||||||
|
when :email
|
||||||
|
dossier.user.email.to_s
|
||||||
|
when :nom_organisation
|
||||||
|
dossier.procedure.organisation.to_s
|
||||||
when :numero_dossier
|
when :numero_dossier
|
||||||
dossier.id.to_s
|
dossier.id.to_s
|
||||||
when :lien_dossier
|
when :lien_dossier
|
||||||
|
|
|
@ -11,8 +11,11 @@ describe MailTemplate do
|
||||||
let(:initiated_mail) { InitiatedMail.default }
|
let(:initiated_mail) { InitiatedMail.default }
|
||||||
|
|
||||||
it 'works' do
|
it 'works' do
|
||||||
initiated_mail.object = '[TPS] --numero_dossier-- --libelle_procedure-- --lien_dossier--'
|
initiated_mail.object = '[TPS] --numero_dossier-- --libelle_procedure-- --lien_dossier-- --email-- --nom_organisation--'
|
||||||
expected = "[TPS] 1 Demande de subvention <a target=\"_blank\" href=\"http://localhost:3000/users/dossiers/1/recapitulatif\">http://localhost:3000/users/dossiers/1/recapitulatif</a>"
|
expected =
|
||||||
|
"[TPS] 1 Demande de subvention " +
|
||||||
|
"<a target=\"_blank\" href=\"http://localhost:3000/users/dossiers/1/recapitulatif\">http://localhost:3000/users/dossiers/1/recapitulatif</a> " +
|
||||||
|
"#{dossier.user.email} Orga SGMAP"
|
||||||
|
|
||||||
expect(initiated_mail.object_for_dossier(dossier)).to eq(expected)
|
expect(initiated_mail.object_for_dossier(dossier)).to eq(expected)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue