feat(tdc): strip libelle so header section titles always start with something
This commit is contained in:
parent
d7880f7e58
commit
1981bfc88e
2 changed files with 10 additions and 0 deletions
|
@ -192,6 +192,7 @@ class TypeDeChamp < ApplicationRecord
|
|||
validates :type_champ, presence: true, allow_blank: false, allow_nil: false
|
||||
|
||||
before_validation :check_mandatory
|
||||
before_validation :normalize_libelle
|
||||
before_save :remove_piece_justificative_template, if: -> { type_champ_changed? }
|
||||
before_validation :remove_drop_down_list, if: -> { type_champ_changed? }
|
||||
before_save :remove_block, if: -> { type_champ_changed? }
|
||||
|
@ -554,4 +555,8 @@ class TypeDeChamp < ApplicationRecord
|
|||
.remove_children_of(self)
|
||||
end
|
||||
end
|
||||
|
||||
def normalize_libelle
|
||||
self.libelle&.strip!
|
||||
end
|
||||
end
|
||||
|
|
|
@ -273,4 +273,9 @@ describe TypeDeChamp do
|
|||
it_behaves_like "a non-prefillable type de champ", :type_de_champ_address
|
||||
it_behaves_like "a non-prefillable type de champ", :type_de_champ_annuaire_education
|
||||
end
|
||||
|
||||
describe '#normalize_libelle' do
|
||||
it { expect(create(:type_de_champ, :header_section, libelle: " 2.3 Test").libelle).to eq("2.3 Test") }
|
||||
it { expect(create(:type_de_champ, libelle: " fix me ").libelle).to eq("fix me") }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue