From ddd3e6bb02e25ff79cc5d58007ff88e100a22b5a Mon Sep 17 00:00:00 2001 From: Christophe Robillard Date: Wed, 29 Apr 2020 16:55:52 +0200 Subject: [PATCH] don't copy api_entreprise_token when cloning except for an admin who owns the parent procedure --- app/models/procedure.rb | 1 + spec/models/procedure_spec.rb | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 7620187b4..60b3c78d6 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -306,6 +306,7 @@ class Procedure < ApplicationRecord if is_different_admin procedure.administrateurs = [admin] + procedure.api_entreprise_token = nil else procedure.administrateurs = administrateurs end diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index 17cf2fd82..7010b4a92 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -461,6 +461,10 @@ describe Procedure do end end + it 'should discard specific api_entreprise_token' do + expect(subject.read_attribute(:api_entreprise_token)).to be_nil + end + it 'should have one administrateur' do expect(subject.administrateurs).to eq([administrateur]) end