do not clone groups instructeurs for admin outside the procedure
This commit is contained in:
parent
7806a26e2c
commit
ed45c88bdf
2 changed files with 18 additions and 7 deletions
|
@ -289,13 +289,13 @@ class Procedure < ApplicationRecord
|
|||
is_different_admin = !admin.owns?(self)
|
||||
|
||||
populate_champ_stable_ids
|
||||
procedure = self.deep_clone(include:
|
||||
{
|
||||
groupe_instructeurs: :instructeurs,
|
||||
attestation_template: nil,
|
||||
types_de_champ: [:drop_down_list, types_de_champ: :drop_down_list],
|
||||
types_de_champ_private: [:drop_down_list, types_de_champ: :drop_down_list]
|
||||
}, &method(:clone_attachments))
|
||||
include_list = {
|
||||
attestation_template: nil,
|
||||
types_de_champ: [:drop_down_list, types_de_champ: :drop_down_list],
|
||||
types_de_champ_private: [:drop_down_list, types_de_champ: :drop_down_list]
|
||||
}
|
||||
include_list[:groupe_instructeurs] = :instructeurs if !is_different_admin
|
||||
procedure = self.deep_clone(include: include_list, &method(:clone_attachments))
|
||||
procedure.path = SecureRandom.uuid
|
||||
procedure.aasm_state = :brouillon
|
||||
procedure.closed_at = nil
|
||||
|
|
|
@ -500,6 +500,17 @@ describe Procedure do
|
|||
it 'should have one administrateur' do
|
||||
expect(subject.administrateurs).to eq([administrateur])
|
||||
end
|
||||
|
||||
it "should discard the existing groupe instructeurs" do
|
||||
expect(subject.groupe_instructeurs.size).not_to eq(procedure.groupe_instructeurs.size)
|
||||
expect(subject.groupe_instructeurs.where(label: "groupe_1").first).to be nil
|
||||
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::DEFAULT_LABEL)
|
||||
expect(subject.groupe_instructeurs.first.instructeurs.size).to eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
it 'should duplicate existing mail_templates' do
|
||||
|
|
Loading…
Reference in a new issue