Merge pull request #9086 from colinux/fix-fork-invalid
ETQ usager je peux modifier un dossier en_construction qui contient des champs en erreur
This commit is contained in:
commit
2c1ad6a624
2 changed files with 27 additions and 1 deletions
|
@ -106,7 +106,7 @@ module DossierCloneConcern
|
|||
end
|
||||
|
||||
transaction do
|
||||
cloned_dossier.save!
|
||||
cloned_dossier.save!(validate: !fork)
|
||||
|
||||
if fork
|
||||
cloned_dossier.rebase!
|
||||
|
|
|
@ -182,6 +182,32 @@ RSpec.describe DossierCloneConcern do
|
|||
expect(champ_pj_fork.updated_at).to eq(champ_pj.updated_at)
|
||||
}
|
||||
end
|
||||
|
||||
context 'invalid origin' do
|
||||
let(:procedure) do
|
||||
create(:procedure, types_de_champ_public: [
|
||||
{ type: :drop_down_list, libelle: "Le savez-vous?", stable_id: 992, drop_down_list_value: ["Oui", "Non", "Peut-être"].join("\r\n"), mandatory: true }
|
||||
])
|
||||
end
|
||||
|
||||
before do
|
||||
champ = dossier.champs.find { _1.stable_id == 992 }
|
||||
champ.value = "Je ne sais pas"
|
||||
champ.save!(validate: false)
|
||||
end
|
||||
|
||||
it 'can still fork' do
|
||||
# rubocop:disable Lint/BooleanSymbol
|
||||
expect(dossier.valid?(context: :false)).to be_falsey
|
||||
|
||||
new_dossier.champs.load # load relation so champs are validated below
|
||||
|
||||
expect(new_dossier.valid?(context: :false)).to be_falsey
|
||||
expect(new_dossier.champs.find { _1.stable_id == 992 }.value).to eq("Je ne sais pas")
|
||||
|
||||
# rubocop:enable Lint/BooleanSymbol
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue