diff --git a/app/models/procedure.rb b/app/models/procedure.rb index bbd74e54d..36ea911dc 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -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: { diff --git a/app/views/administrateurs/procedures/_informations.html.haml b/app/views/administrateurs/procedures/_informations.html.haml index d39df9c68..972a36d51 100644 --- a/app/views/administrateurs/procedures/_informations.html.haml +++ b/app/views/administrateurs/procedures/_informations.html.haml @@ -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) diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index 8334057eb..4a5508d2a 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -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 diff --git a/spec/system/administrateurs/procedure_creation_spec.rb b/spec/system/administrateurs/procedure_creation_spec.rb index e7442627a..c9a684209 100644 --- a/spec/system/administrateurs/procedure_creation_spec.rb +++ b/spec/system/administrateurs/procedure_creation_spec.rb @@ -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'