build raison sociale from nom and nom
This commit is contained in:
parent
9bd6cea38d
commit
67b9bb264a
2 changed files with 34 additions and 0 deletions
|
@ -66,6 +66,16 @@ class Etablissement < ApplicationRecord
|
|||
fermé: "fermé"
|
||||
}, _prefix: true
|
||||
|
||||
def entreprise_raison_sociale
|
||||
read_attribute(:entreprise_raison_sociale).presence || raison_sociale_for_ei
|
||||
end
|
||||
|
||||
def raison_sociale_for_ei
|
||||
if entreprise_nom || entreprise_prenom
|
||||
[entreprise_nom, entreprise_prenom].join(' ')
|
||||
end
|
||||
end
|
||||
|
||||
def search_terms
|
||||
[
|
||||
entreprise_siren,
|
||||
|
|
|
@ -36,6 +36,30 @@ describe Etablissement do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#entreprise_raison_sociale' do
|
||||
subject { etablissement.entreprise_raison_sociale }
|
||||
|
||||
context "with nom and prenom" do
|
||||
context "without raison sociale" do
|
||||
let(:etablissement) { create(:etablissement, entreprise_raison_sociale: nil, entreprise_prenom: "Stef", entreprise_nom: "Sanseverino") }
|
||||
|
||||
it { is_expected.to eq "Sanseverino Stef" }
|
||||
end
|
||||
|
||||
context "with raison sociale" do
|
||||
let(:etablissement) { create(:etablissement, entreprise_raison_sociale: "Sansev Prod", entreprise_prenom: "Stef", entreprise_nom: "Sanseverino") }
|
||||
|
||||
it { is_expected.to eq "Sansev Prod" }
|
||||
end
|
||||
end
|
||||
|
||||
context "without nom and prenom" do
|
||||
let(:etablissement) { create(:etablissement, entreprise_raison_sociale: "ENGIE", entreprise_prenom: nil, entreprise_nom: nil) }
|
||||
|
||||
it { is_expected.to eq "ENGIE" }
|
||||
end
|
||||
end
|
||||
|
||||
describe '.entreprise_bilans_bdf_to_csv' do
|
||||
let(:etablissement) { build(:etablissement, entreprise_bilans_bdf: bilans) }
|
||||
let(:ordered_headers) {
|
||||
|
|
Loading…
Reference in a new issue