refactor(dossier): rename check_mandatory_champs -> check_mandatory_and_visible_champs
This commit is contained in:
parent
9bba2093be
commit
fbf089d60e
3 changed files with 6 additions and 5 deletions
|
@ -462,7 +462,7 @@ module Users
|
||||||
end
|
end
|
||||||
|
|
||||||
if dossier.en_construction?
|
if dossier.en_construction?
|
||||||
errors += @dossier.check_mandatory_champs
|
errors += @dossier.check_mandatory_and_visible_champs
|
||||||
end
|
end
|
||||||
|
|
||||||
errors
|
errors
|
||||||
|
@ -473,7 +473,7 @@ module Users
|
||||||
|
|
||||||
@dossier.valid?(**submit_validation_options)
|
@dossier.valid?(**submit_validation_options)
|
||||||
errors += @dossier.errors.full_messages
|
errors += @dossier.errors.full_messages
|
||||||
errors += @dossier.check_mandatory_champs
|
errors += @dossier.check_mandatory_and_visible_champs
|
||||||
|
|
||||||
if should_fill_groupe_instructeur?
|
if should_fill_groupe_instructeur?
|
||||||
@dossier.assign_to_groupe_instructeur(defaut_groupe_instructeur)
|
@dossier.assign_to_groupe_instructeur(defaut_groupe_instructeur)
|
||||||
|
|
|
@ -981,8 +981,9 @@ class Dossier < ApplicationRecord
|
||||||
champs.filter(&:titre_identite?).map(&:piece_justificative_file).each(&:purge_later)
|
champs.filter(&:titre_identite?).map(&:piece_justificative_file).each(&:purge_later)
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_mandatory_champs
|
def check_mandatory_and_visible_champs
|
||||||
(champs + champs.filter(&:block?).filter(&:visible?).flat_map(&:champs))
|
(champs + champs.filter(&:block?).filter(&:visible?).flat_map(&:champs))
|
||||||
|
.filter(&:visible?)
|
||||||
.filter(&:mandatory_blank?)
|
.filter(&:mandatory_blank?)
|
||||||
.map do |champ|
|
.map do |champ|
|
||||||
"Le champ #{champ.libelle.truncate(200)} doit être rempli."
|
"Le champ #{champ.libelle.truncate(200)} doit être rempli."
|
||||||
|
|
|
@ -1172,14 +1172,14 @@ describe Dossier do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#check_mandatory_champs" do
|
describe "#check_mandatory_and_visible_champs" do
|
||||||
include Logic
|
include Logic
|
||||||
|
|
||||||
let(:procedure) { create(:procedure, types_de_champ_public: types_de_champ) }
|
let(:procedure) { create(:procedure, types_de_champ_public: types_de_champ) }
|
||||||
let(:dossier) { create(:dossier, procedure: procedure) }
|
let(:dossier) { create(:dossier, procedure: procedure) }
|
||||||
let(:types_de_champ) { [type_de_champ] }
|
let(:types_de_champ) { [type_de_champ] }
|
||||||
let(:type_de_champ) { {} }
|
let(:type_de_champ) { {} }
|
||||||
let(:errors) { dossier.check_mandatory_champs }
|
let(:errors) { dossier.check_mandatory_and_visible_champs }
|
||||||
|
|
||||||
it 'no mandatory champs' do
|
it 'no mandatory champs' do
|
||||||
expect(errors).to be_empty
|
expect(errors).to be_empty
|
||||||
|
|
Loading…
Add table
Reference in a new issue