Merge pull request #8093 from demarches-simplifiees/clean_invalid_procedures
fix(procedures): valides uniquement le juridique a la création et à la publication
This commit is contained in:
commit
d6cbf738a1
4 changed files with 11 additions and 10 deletions
|
@ -272,7 +272,9 @@ class Procedure < ApplicationRecord
|
|||
'types_de_champ/no_empty_block': true,
|
||||
'types_de_champ/no_empty_drop_down': true,
|
||||
on: :publication
|
||||
validate :check_juridique
|
||||
|
||||
validate :check_juridique, on: [:create, :publication]
|
||||
|
||||
validates :path, presence: true, format: { with: /\A[a-z0-9_\-]{3,200}\z/ }, uniqueness: { scope: [:path, :closed_at, :hidden_at, :unpublished_at], case_sensitive: false }
|
||||
validates :duree_conservation_dossiers_dans_ds, allow_nil: false,
|
||||
numericality: {
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
= f.label :libelle do
|
||||
Titre de la démarche
|
||||
%span.mandatory *
|
||||
= f.text_field :libelle, class: 'form-control', placeholder: 'Titre'
|
||||
= f.text_field :libelle, class: 'form-control', placeholder: 'Titre', required: true
|
||||
|
||||
= f.label :description do
|
||||
Description
|
||||
%span.mandatory *
|
||||
= f.text_area :description, rows: '6', placeholder: 'Description de la démarche, destinataires, etc. ', class: 'form-control'
|
||||
= f.text_area :description, rows: '6', placeholder: 'Description de la démarche, destinataires, etc. ', class: 'form-control', required: true
|
||||
|
||||
%h3.header-subsection Logo de la démarche
|
||||
= render Attachment::EditComponent.new(attached_file: @procedure.logo, view_as: :link)
|
||||
|
|
|
@ -178,20 +178,20 @@ describe Procedure do
|
|||
end
|
||||
|
||||
context 'juridique' do
|
||||
it { is_expected.not_to allow_value(nil).for(:cadre_juridique) }
|
||||
it { is_expected.to allow_value('text').for(:cadre_juridique) }
|
||||
it { is_expected.not_to allow_value(nil).on(:publication).for(:cadre_juridique) }
|
||||
it { is_expected.to allow_value('text').on(:publication).for(:cadre_juridique) }
|
||||
|
||||
context 'with deliberation' do
|
||||
let(:procedure) { build(:procedure, cadre_juridique: nil) }
|
||||
|
||||
it { expect(procedure.valid?).to eq(false) }
|
||||
it { expect(procedure.valid?(:publication)).to eq(false) }
|
||||
|
||||
context 'when the deliberation is uploaded ' do
|
||||
before do
|
||||
procedure.deliberation = fixture_file_upload('spec/fixtures/files/file.pdf', 'application/pdf')
|
||||
end
|
||||
|
||||
it { expect(procedure.valid?).to eq(true) }
|
||||
it { expect(procedure.valid?(:publication)).to eq(true) }
|
||||
end
|
||||
|
||||
context 'when the deliberation is uploaded with an unauthorized format' do
|
||||
|
@ -199,14 +199,14 @@ describe Procedure do
|
|||
procedure.deliberation = fixture_file_upload('spec/fixtures/files/french-flag.gif', 'image/gif')
|
||||
end
|
||||
|
||||
it { expect(procedure.valid?).to eq(false) }
|
||||
it { expect(procedure.valid?(:publication)).to eq(false) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when juridique_required is false' do
|
||||
let(:procedure) { build(:procedure, juridique_required: false, cadre_juridique: nil) }
|
||||
|
||||
it { expect(procedure.valid?).to eq(true) }
|
||||
it { expect(procedure.valid?(:publication)).to eq(true) }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ describe 'Creating a new procedure', js: true do
|
|||
fill_in 'procedure_duree_conservation_dossiers_dans_ds', with: '3'
|
||||
click_on 'Créer la démarche'
|
||||
|
||||
expect(page).to have_text('Le champ « Libelle » doit être rempli')
|
||||
fill_in_dummy_procedure_details
|
||||
click_on 'Créer la démarche'
|
||||
|
||||
|
|
Loading…
Reference in a new issue