[Fix #1203] No début d’instruction tag in accusé de réception mails

Doesn’t make sense functionnally
This commit is contained in:
Frederic Merizen 2018-01-11 11:28:41 +01:00
parent 9f7ffddb31
commit eebab14954
3 changed files with 19 additions and 1 deletions

View file

@ -51,7 +51,8 @@ module TagsSubstitutionConcern
{ {
libelle: 'date de passage en instruction', libelle: 'date de passage en instruction',
description: '', description: '',
lambda: -> (d) { format_date(d.en_instruction_at) } lambda: -> (d) { format_date(d.en_instruction_at) },
available_for_states: Dossier::INSTRUCTION_COMMENCEE
}, },
{ {
libelle: 'date de décision', libelle: 'date de décision',

View file

@ -10,6 +10,7 @@ class Dossier < ActiveRecord::Base
EN_CONSTRUCTION_OU_INSTRUCTION = %w(en_construction en_instruction) EN_CONSTRUCTION_OU_INSTRUCTION = %w(en_construction en_instruction)
TERMINE = %w(accepte refuse sans_suite) TERMINE = %w(accepte refuse sans_suite)
INSTRUCTION_COMMENCEE = TERMINE + %w(en_instruction)
has_one :etablissement, dependent: :destroy has_one :etablissement, dependent: :destroy
has_one :entreprise, dependent: :destroy has_one :entreprise, dependent: :destroy

View file

@ -47,6 +47,22 @@ describe MailTemplateConcern do
it_behaves_like "can replace tokens in template" it_behaves_like "can replace tokens in template"
end end
describe 'tags' do
describe 'in initiated mail' do
it "does not treat date de passage en instruction as a tag" do
expect(initiated_mail.tags).not_to include(include({ libelle: 'date de passage en instruction' }))
end
end
describe 'in received mail' do
let(:received_mail) { create(:received_mail, procedure: procedure) }
it "treats date de passage en instruction as a tag" do
expect(received_mail.tags).to include(include({ libelle: 'date de passage en instruction' }))
end
end
end
describe '.replace_tags' do describe '.replace_tags' do
before { initiated_mail.body = "n --numéro du dossier--" } before { initiated_mail.body = "n --numéro du dossier--" }
it "avoids side effects" do it "avoids side effects" do