fix(procedure): validates presence of replaced_by_id if procedure redirected
This commit is contained in:
parent
61a9bedfff
commit
e55531c6f4
2 changed files with 5 additions and 5 deletions
|
@ -265,8 +265,7 @@ class Procedure < ApplicationRecord
|
||||||
|
|
||||||
validate :check_juridique, on: [:create, :publication]
|
validate :check_juridique, on: [:create, :publication]
|
||||||
|
|
||||||
# TO DO add validation after data backfill
|
validates :replaced_by_procedure_id, presence: true, if: -> { closing_reason == Procedure.closing_reasons.fetch(:internal_procedure) }
|
||||||
# validates :replaced_by_id, presence: true, if: -> { closing_reason == self.closing_reasons.fetch(:internal_procedure) }
|
|
||||||
|
|
||||||
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 :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,
|
validates :duree_conservation_dossiers_dans_ds, allow_nil: false,
|
||||||
|
|
|
@ -803,9 +803,10 @@ describe Administrateurs::ProceduresController, type: :controller do
|
||||||
procedure.reload
|
procedure.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'closes the procedure without redirection to the new procedure in DS' do
|
it 'does not close the procedure' do
|
||||||
expect(response).to redirect_to admin_procedure_path(procedure.id)
|
expect(response).to redirect_to admin_procedure_close_path
|
||||||
expect(flash[:notice]).to have_content 'Démarche close'
|
expect(flash[:alert]).to have_content 'Le champ « Nouvelle démarche » doit être rempli'
|
||||||
|
expect(procedure.close?).to be_falsey
|
||||||
expect(procedure.replaced_by_procedure).to eq(nil)
|
expect(procedure.replaced_by_procedure).to eq(nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue