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: '',
|
||||
target: :raison_sociale,
|
||||
available_for_states: Dossier::SOUMIS
|
||||
}
|
||||
]
|
||||
|
||||
ETABLISSEMENT_TAGS = [
|
||||
},
|
||||
{
|
||||
libelle: 'adresse',
|
||||
description: '',
|
||||
target: :inline_adresse,
|
||||
lambda: -> (e) { e&.etablissement&.inline_adresse },
|
||||
available_for_states: Dossier::SOUMIS
|
||||
}
|
||||
]
|
||||
|
@ -113,7 +110,7 @@ module TagsSubstitutionConcern
|
|||
if procedure.for_individual?
|
||||
identity_tags = INDIVIDUAL_TAGS
|
||||
else
|
||||
identity_tags = ENTREPRISE_TAGS + ETABLISSEMENT_TAGS
|
||||
identity_tags = ENTREPRISE_TAGS
|
||||
end
|
||||
|
||||
filter_tags(identity_tags + dossier_tags + champ_public_tags + champ_private_tags)
|
||||
|
@ -185,8 +182,7 @@ module TagsSubstitutionConcern
|
|||
tags_and_datas = [
|
||||
[dossier_tags, dossier],
|
||||
[INDIVIDUAL_TAGS, dossier.individual],
|
||||
[ENTREPRISE_TAGS, dossier.entreprise],
|
||||
[ETABLISSEMENT_TAGS, dossier.entreprise&.etablissement]
|
||||
[ENTREPRISE_TAGS, dossier.entreprise]
|
||||
]
|
||||
|
||||
tags_and_datas
|
||||
|
|
|
@ -58,19 +58,13 @@ describe TagsSubstitutionConcern, type: :model do
|
|||
let(:template) do
|
||||
'--SIREN-- --numéro de TVA intracommunautaire-- --SIRET du siège social-- --raison sociale-- --adresse--'
|
||||
end
|
||||
let(:etablissement) { create(:etablissement) }
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue