diff --git a/app/models/procedure.rb b/app/models/procedure.rb index b5a1c22a6..c85b5de02 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -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 diff --git a/lib/tasks/deployment/20230921132123_unroute_cloned_procedures_from_diffent_admin.rake b/lib/tasks/deployment/20230921132123_unroute_cloned_procedures_from_diffent_admin.rake new file mode 100644 index 000000000..9e4bb9b4b --- /dev/null +++ b/lib/tasks/deployment/20230921132123_unroute_cloned_procedures_from_diffent_admin.rake @@ -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 diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index 8d3f9c21f..849841d5a 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -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)