Merge pull request #9504 from demarches-simplifiees/do-not-route-cloned-procedures-if-admin-is-different

Correction : désactive le routage des procédures clonées si l'admin n'est pas aussi admin de la procédure parente
This commit is contained in:
Eric Leroy-Terquem 2023-09-22 09:10:42 +00:00 committed by GitHub
commit 1060aadff7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 0 deletions

View file

@ -495,6 +495,7 @@ class Procedure < ApplicationRecord
procedure.encrypted_api_particulier_token = nil procedure.encrypted_api_particulier_token = nil
procedure.opendata = true procedure.opendata = true
procedure.api_particulier_scopes = [] procedure.api_particulier_scopes = []
procedure.routing_enabled = false
else else
procedure.administrateurs = administrateurs procedure.administrateurs = administrateurs
end end

View file

@ -0,0 +1,18 @@
namespace :after_party do
desc 'Deployment task: unroute_cloned_procedures_from_diffent_admin'
task unroute_cloned_procedures_from_diffent_admin: :environment do
puts "Running deploy task 'unroute_cloned_procedures_from_diffent_admin'"
# Put your task implementation HERE.
Procedure
.with_discarded
.where(routing_enabled: true)
.filter { |p| p.groupe_instructeurs.active.count == 1 }
.update_all(routing_enabled: false)
# Update task as completed. If you remove the line below, the task will
# run with every deploy (or every time you call after_party:run).
AfterParty::TaskRecord
.create version: AfterParty::TaskRecorder.new(__FILE__).timestamp
end
end

View file

@ -747,6 +747,10 @@ describe Procedure do
expect(subject.api_particulier_scopes).to be_empty expect(subject.api_particulier_scopes).to be_empty
end end
it 'should not route the procedure' do
expect(subject.routing_enabled).to eq(false)
end
it 'should have a default groupe instructeur' do it 'should have a default groupe instructeur' do
expect(subject.groupe_instructeurs.size).to eq(1) expect(subject.groupe_instructeurs.size).to eq(1)
expect(subject.groupe_instructeurs.first.label).to eq(GroupeInstructeur::DEFAUT_LABEL) expect(subject.groupe_instructeurs.first.label).to eq(GroupeInstructeur::DEFAUT_LABEL)