Merge pull request #1308 from betagouv/lambda_tags
Use lambda instead of send for etablissement tag
This commit is contained in:
commit
900fdc81ef
2 changed files with 6 additions and 16 deletions
|
@ -97,14 +97,11 @@ module TagsSubstitutionConcern
|
||||||
description: '',
|
description: '',
|
||||||
target: :raison_sociale,
|
target: :raison_sociale,
|
||||||
available_for_states: Dossier::SOUMIS
|
available_for_states: Dossier::SOUMIS
|
||||||
}
|
},
|
||||||
]
|
|
||||||
|
|
||||||
ETABLISSEMENT_TAGS = [
|
|
||||||
{
|
{
|
||||||
libelle: 'adresse',
|
libelle: 'adresse',
|
||||||
description: '',
|
description: '',
|
||||||
target: :inline_adresse,
|
lambda: -> (e) { e&.etablissement&.inline_adresse },
|
||||||
available_for_states: Dossier::SOUMIS
|
available_for_states: Dossier::SOUMIS
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -113,7 +110,7 @@ module TagsSubstitutionConcern
|
||||||
if procedure.for_individual?
|
if procedure.for_individual?
|
||||||
identity_tags = INDIVIDUAL_TAGS
|
identity_tags = INDIVIDUAL_TAGS
|
||||||
else
|
else
|
||||||
identity_tags = ENTREPRISE_TAGS + ETABLISSEMENT_TAGS
|
identity_tags = ENTREPRISE_TAGS
|
||||||
end
|
end
|
||||||
|
|
||||||
filter_tags(identity_tags + dossier_tags + champ_public_tags + champ_private_tags)
|
filter_tags(identity_tags + dossier_tags + champ_public_tags + champ_private_tags)
|
||||||
|
@ -185,8 +182,7 @@ module TagsSubstitutionConcern
|
||||||
tags_and_datas = [
|
tags_and_datas = [
|
||||||
[dossier_tags, dossier],
|
[dossier_tags, dossier],
|
||||||
[INDIVIDUAL_TAGS, dossier.individual],
|
[INDIVIDUAL_TAGS, dossier.individual],
|
||||||
[ENTREPRISE_TAGS, dossier.entreprise],
|
[ENTREPRISE_TAGS, dossier.entreprise]
|
||||||
[ETABLISSEMENT_TAGS, dossier.entreprise&.etablissement]
|
|
||||||
]
|
]
|
||||||
|
|
||||||
tags_and_datas
|
tags_and_datas
|
||||||
|
|
|
@ -58,19 +58,13 @@ describe TagsSubstitutionConcern, type: :model do
|
||||||
let(:template) do
|
let(:template) do
|
||||||
'--SIREN-- --numéro de TVA intracommunautaire-- --SIRET du siège social-- --raison sociale-- --adresse--'
|
'--SIREN-- --numéro de TVA intracommunautaire-- --SIRET du siège social-- --raison sociale-- --adresse--'
|
||||||
end
|
end
|
||||||
|
let(:etablissement) { create(:etablissement) }
|
||||||
|
|
||||||
let(:expected_text) do
|
let(:expected_text) do
|
||||||
"#{entreprise.siren} #{entreprise.numero_tva_intracommunautaire} #{entreprise.siret_siege_social} #{entreprise.raison_sociale} --adresse--"
|
"#{entreprise.siren} #{entreprise.numero_tva_intracommunautaire} #{entreprise.siret_siege_social} #{entreprise.raison_sociale} #{etablissement.inline_adresse}"
|
||||||
end
|
end
|
||||||
|
|
||||||
it { is_expected.to eq(expected_text) }
|
it { is_expected.to eq(expected_text) }
|
||||||
|
|
||||||
context 'and the entreprise has a etablissement with an adresse' do
|
|
||||||
let(:etablissement) { create(:etablissement, adresse: 'adresse') }
|
|
||||||
let(:template) { '--adresse--' }
|
|
||||||
|
|
||||||
it { is_expected.to eq(etablissement.inline_adresse) }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue