[#1203] Do not include champs privés in accusé de réception

This commit is contained in:
Frederic Merizen 2018-01-18 18:06:40 +01:00
parent a21dee680d
commit 8f41ab89cf
2 changed files with 62 additions and 9 deletions

View file

@ -131,10 +131,10 @@ describe TagsSubstitutionConcern, type: :model do
context 'when the procedure has a type de champ prive named libelleA' do
let(:types_de_champ_private) { [create(:type_de_champ_private, libelle: 'libelleA')] }
context 'and the are used in the template' do
context 'and it is used in the template' do
let(:template) { '--libelleA--' }
context 'and its value in the dossier are not nil' do
context 'and its value in the dossier is not nil' do
before { dossier.champs_private.first.update_attributes(value: 'libelle1') }
it { is_expected.to eq('libelle1') }
@ -142,6 +142,28 @@ describe TagsSubstitutionConcern, type: :model do
end
end
context 'when the dossier is en construction' do
let(:state) { 'en_construction' }
let(:template) { '--libelleA--' }
context 'champs privés are not valid tags' do
# The dossier just transitionned from brouillon to en construction,
# so champs private are not valid tags yet
let(:types_de_champ_private) { [create(:type_de_champ_private, libelle: 'libelleA')] }
it { is_expected.to eq('--libelleA--') }
end
context 'champs publics are valid tags' do
let(:types_de_champ) { [create(:type_de_champ_public, libelle: 'libelleA')] }
before { dossier.champs.first.update_attributes(value: 'libelle1') }
it { is_expected.to eq('libelle1') }
end
end
context 'when the procedure has 2 types de champ date and datetime' do
let(:types_de_champ) do
[
@ -249,16 +271,34 @@ describe TagsSubstitutionConcern, type: :model do
describe 'tags' do
subject { template_concern.tags }
let(:types_de_champ) { [create(:type_de_champ_public, libelle: 'public')] }
let(:types_de_champ_private) { [create(:type_de_champ_private, libelle: 'privé')] }
context 'when generating a document for a dossier terminé' do
it { is_expected.to include(include({ libelle: 'motivation' })) }
it { is_expected.to include(include({ libelle: 'date de décision' })) }
it { is_expected.to include(include({ libelle: 'public' })) }
it { is_expected.to include(include({ libelle: 'privé' })) }
end
context 'when generating a document for a dossier that is not terminé' do
context 'when generating a document for a dossier en instruction' do
let(:state) { 'en_instruction' }
it { is_expected.not_to include(include({ libelle: 'motivation' })) }
it { is_expected.not_to include(include({ libelle: 'date de décision' })) }
it { is_expected.to include(include({ libelle: 'public' })) }
it { is_expected.to include(include({ libelle: 'privé' })) }
end
context 'when generating a document for a dossier en construction' do
let(:state) { 'en_construction' }
it { is_expected.not_to include(include({ libelle: 'motivation' })) }
it { is_expected.not_to include(include({ libelle: 'date de décision' })) }
it { is_expected.not_to include(include({ libelle: 'privé' })) }
it { is_expected.to include(include({ libelle: 'public' })) }
end
end
end