a champ is mandatory when visible with a mandatory tdc
This commit is contained in:
parent
ec40836589
commit
898badb579
5 changed files with 20 additions and 5 deletions
|
@ -34,7 +34,6 @@ class Champ < ApplicationRecord
|
|||
delegate :libelle,
|
||||
:type_champ,
|
||||
:procedure,
|
||||
:mandatory?,
|
||||
:description,
|
||||
:drop_down_list_options,
|
||||
:drop_down_other?,
|
||||
|
@ -92,8 +91,12 @@ class Champ < ApplicationRecord
|
|||
@sections ||= dossier.sections_for(self)
|
||||
end
|
||||
|
||||
def mandatory?
|
||||
type_de_champ.mandatory? && visible?
|
||||
end
|
||||
|
||||
def mandatory_blank_and_visible?
|
||||
mandatory? && blank? && visible?
|
||||
mandatory? && blank?
|
||||
end
|
||||
|
||||
def blank?
|
||||
|
|
|
@ -39,7 +39,7 @@ class Champs::PieceJustificativeChamp < Champ
|
|||
end
|
||||
|
||||
def mandatory_blank_and_visible?
|
||||
mandatory? && !piece_justificative_file.attached? && visible?
|
||||
mandatory? && !piece_justificative_file.attached?
|
||||
end
|
||||
|
||||
def for_export
|
||||
|
|
|
@ -25,6 +25,6 @@ class Champs::SiretChamp < Champ
|
|||
end
|
||||
|
||||
def mandatory_blank_and_visible?
|
||||
mandatory? && Siret.new(siret: value).invalid? && visible?
|
||||
mandatory? && Siret.new(siret: value).invalid?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -33,7 +33,7 @@ class Champs::TitreIdentiteChamp < Champ
|
|||
end
|
||||
|
||||
def mandatory_blank_and_visible?
|
||||
mandatory? && !piece_justificative_file.attached? && visible?
|
||||
mandatory? && !piece_justificative_file.attached?
|
||||
end
|
||||
|
||||
def for_export
|
||||
|
|
|
@ -292,6 +292,18 @@ describe 'The user' do
|
|||
click_on 'Déposer le dossier'
|
||||
expect(page).to have_current_path(merci_dossier_path(user_dossier))
|
||||
end
|
||||
|
||||
scenario 'cannot submit a reveal dossier with a revealed mandatory champ ', js: true do
|
||||
log_in(user, procedure)
|
||||
|
||||
fill_individual
|
||||
|
||||
fill_in('age', with: '18')
|
||||
expect(page).to have_css('label', text: 'nom', visible: :visible)
|
||||
|
||||
click_on 'Déposer le dossier'
|
||||
expect(page).to have_current_path(brouillon_dossier_path(user_dossier))
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a visibilite in cascade' do
|
||||
|
|
Loading…
Reference in a new issue