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:
commit
1060aadff7
3 changed files with 23 additions and 0 deletions
|
@ -495,6 +495,7 @@ class Procedure < ApplicationRecord
|
|||
procedure.encrypted_api_particulier_token = nil
|
||||
procedure.opendata = true
|
||||
procedure.api_particulier_scopes = []
|
||||
procedure.routing_enabled = false
|
||||
else
|
||||
procedure.administrateurs = administrateurs
|
||||
end
|
||||
|
|
|
@ -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
|
|
@ -747,6 +747,10 @@ describe Procedure do
|
|||
expect(subject.api_particulier_scopes).to be_empty
|
||||
end
|
||||
|
||||
it 'should not route the procedure' do
|
||||
expect(subject.routing_enabled).to eq(false)
|
||||
end
|
||||
|
||||
it 'should have a default groupe instructeur' do
|
||||
expect(subject.groupe_instructeurs.size).to eq(1)
|
||||
expect(subject.groupe_instructeurs.first.label).to eq(GroupeInstructeur::DEFAUT_LABEL)
|
||||
|
|
Loading…
Reference in a new issue