Merge pull request #10757 from mfo/US/fix-required-dossier-link-with-missing-dossier
correct: ETQ administrateur, je souhaite que les types de champ liens vers un dossier pointent vers un dossier valide si ils sont obligatoire
This commit is contained in:
commit
977e47fa74
5 changed files with 54 additions and 6 deletions
|
@ -36,4 +36,34 @@ describe Champs::DossierLinkChamp, type: :model do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'validation' do
|
||||
let(:champ) { Champs::DossierLinkChamp.new(value:, dossier: build(:dossier)) }
|
||||
|
||||
before do
|
||||
allow(champ).to receive(:type_de_champ).and_return(build(:type_de_champ_dossier_link, mandatory:))
|
||||
champ.run_callbacks(:validation)
|
||||
end
|
||||
|
||||
subject { champ.validate(:champs_public_value) }
|
||||
|
||||
context 'when not mandatory' do
|
||||
let(:mandatory) { false }
|
||||
let(:value) { nil }
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
|
||||
context 'when mandatory' do
|
||||
let(:mandatory) { true }
|
||||
context 'when valid id' do
|
||||
let(:value) { create(:dossier).id }
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
|
||||
context 'when invalid id' do
|
||||
let(:value) { 'kthxbye' }
|
||||
it { is_expected.to be_falsey }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue