Merge pull request #3579 from betagouv/frederic/fix_3578-no_tags_for_static_champs

[Fix #3578] No tags for champs that cannot have user input anyway
This commit is contained in:
Pierre de La Morinerie 2019-03-11 11:14:41 +01:00 committed by GitHub
commit b9146b8892
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 1 deletions

View file

@ -1,2 +1,5 @@
class TypesDeChamp::ExplicationTypeDeChamp < TypesDeChamp::TextTypeDeChamp
def tags_for_template
[]
end
end

View file

@ -1,2 +1,5 @@
class TypesDeChamp::HeaderSectionTypeDeChamp < TypesDeChamp::TypeDeChampBase
def tags_for_template
[]
end
end

View file

@ -321,9 +321,20 @@ describe TagsSubstitutionConcern, type: :model do
describe 'tags' do
subject { template_concern.tags }
let(:types_de_champ) { [create(:type_de_champ, libelle: 'public')] }
let(:types_de_champ) do
[
create(:type_de_champ, libelle: 'public'),
create(:type_de_champ_header_section, libelle: 'entête de section'),
create(:type_de_champ_explication, libelle: 'explication')
]
end
let(:types_de_champ_private) { [create(:type_de_champ, :private, libelle: 'privé')] }
context 'do not generate tags for champs that cannot have usager content' do
it { is_expected.not_to include(include({ libelle: 'entête de section' })) }
it { is_expected.not_to include(include({ libelle: 'explication' })) }
end
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' })) }