reset opendata to true when procedure is cloned by another admin
This commit is contained in:
parent
45d48bd269
commit
6dd27ec7ed
2 changed files with 15 additions and 0 deletions
|
@ -487,6 +487,7 @@ class Procedure < ApplicationRecord
|
||||||
procedure.administrateurs = [admin]
|
procedure.administrateurs = [admin]
|
||||||
procedure.api_entreprise_token = nil
|
procedure.api_entreprise_token = nil
|
||||||
procedure.encrypted_api_particulier_token = nil
|
procedure.encrypted_api_particulier_token = nil
|
||||||
|
procedure.opendata = true
|
||||||
procedure.api_particulier_scopes = []
|
procedure.api_particulier_scopes = []
|
||||||
else
|
else
|
||||||
procedure.administrateurs = administrateurs
|
procedure.administrateurs = administrateurs
|
||||||
|
|
|
@ -439,6 +439,7 @@ describe Procedure do
|
||||||
create(:procedure,
|
create(:procedure,
|
||||||
received_mail: received_mail,
|
received_mail: received_mail,
|
||||||
service: service,
|
service: service,
|
||||||
|
opendata: opendata,
|
||||||
attestation_template: build(:attestation_template, logo: logo, signature: signature),
|
attestation_template: build(:attestation_template, logo: logo, signature: signature),
|
||||||
types_de_champ: [type_de_champ_0, type_de_champ_1, type_de_champ_2, type_de_champ_pj],
|
types_de_champ: [type_de_champ_0, type_de_champ_1, type_de_champ_2, type_de_champ_pj],
|
||||||
types_de_champ_private: [type_de_champ_private_0, type_de_champ_private_1, type_de_champ_private_2],
|
types_de_champ_private: [type_de_champ_private_0, type_de_champ_private_1, type_de_champ_private_2],
|
||||||
|
@ -456,6 +457,7 @@ describe Procedure do
|
||||||
let(:type_de_champ_private_repetition) { build(:type_de_champ_repetition, :private, position: 3, procedure: procedure, types_de_champ: [build(:type_de_champ, :private)]) }
|
let(:type_de_champ_private_repetition) { build(:type_de_champ_repetition, :private, position: 3, procedure: procedure, types_de_champ: [build(:type_de_champ, :private)]) }
|
||||||
let(:received_mail) { build(:received_mail) }
|
let(:received_mail) { build(:received_mail) }
|
||||||
let(:from_library) { false }
|
let(:from_library) { false }
|
||||||
|
let(:opendata) { true }
|
||||||
let(:administrateur) { procedure.administrateurs.first }
|
let(:administrateur) { procedure.administrateurs.first }
|
||||||
let(:logo) { Rack::Test::UploadedFile.new('spec/fixtures/files/white.png', 'image/png') }
|
let(:logo) { Rack::Test::UploadedFile.new('spec/fixtures/files/white.png', 'image/png') }
|
||||||
let(:signature) { Rack::Test::UploadedFile.new('spec/fixtures/files/black.png', 'image/png') }
|
let(:signature) { Rack::Test::UploadedFile.new('spec/fixtures/files/black.png', 'image/png') }
|
||||||
|
@ -529,6 +531,13 @@ describe Procedure do
|
||||||
expect(cloned_procedure).to have_same_attributes_as(procedure, except: ["path", "draft_revision_id"])
|
expect(cloned_procedure).to have_same_attributes_as(procedure, except: ["path", "draft_revision_id"])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'which is opendata' do
|
||||||
|
let(:opendata) { false }
|
||||||
|
it 'should keep opendata for same admin' do
|
||||||
|
expect(subject.opendata).to be_falsy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'when the procedure is cloned from the library' do
|
context 'when the procedure is cloned from the library' do
|
||||||
let(:from_library) { true }
|
let(:from_library) { true }
|
||||||
|
|
||||||
|
@ -569,6 +578,7 @@ describe Procedure do
|
||||||
|
|
||||||
context 'when the procedure is cloned to another administrateur' do
|
context 'when the procedure is cloned to another administrateur' do
|
||||||
let(:administrateur) { create(:administrateur) }
|
let(:administrateur) { create(:administrateur) }
|
||||||
|
let(:opendata) { false }
|
||||||
|
|
||||||
it 'should clone service' do
|
it 'should clone service' do
|
||||||
expect(subject.service.id).not_to eq(service.id)
|
expect(subject.service.id).not_to eq(service.id)
|
||||||
|
@ -586,6 +596,10 @@ describe Procedure do
|
||||||
expect(subject.read_attribute(:api_entreprise_token)).to be_nil
|
expect(subject.read_attribute(:api_entreprise_token)).to be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should reset opendata to true' do
|
||||||
|
expect(subject.opendata).to be_truthy
|
||||||
|
end
|
||||||
|
|
||||||
it 'should have one administrateur' do
|
it 'should have one administrateur' do
|
||||||
expect(subject.administrateurs).to eq([administrateur])
|
expect(subject.administrateurs).to eq([administrateur])
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue