From 5a9c80aab819365f7405ca393f35cb15f4f96124 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Mon, 18 Nov 2024 23:07:20 +0100 Subject: [PATCH] [#9513] add test case --- spec/models/procedure_spec.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index 2a072414f74..4057e4fe395 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -1126,6 +1126,15 @@ expect(procedure.revisions).to eq([procedure.published_revision, procedure.draft_revision]) end end + + context 'when publishing a procedure with the same path as another procedure from another admin' do + let(:procedure) { create(:procedure, path: 'example-path', administrateurs: [administrateur]) } + let(:other_procedure) { create(:procedure, path: 'example-path', administrateurs: [create(:administrateur)]) } + + it 'raises an error' do + expect { procedure.publish_or_reopen!(administrateur, other_procedure.path) }.to raise_error(ActiveRecord::RecordInvalid) + end + end end describe "#publish_revision!" do