allow draft to be saved with invalid cnaf champ
This commit is contained in:
parent
cd7bafaa0d
commit
87de9e38c6
4 changed files with 42 additions and 12 deletions
|
@ -125,14 +125,23 @@ feature 'fetch API Particulier Data', js: true do
|
|||
click_button('Continuer')
|
||||
|
||||
fill_in 'Le numéro d’allocataire CAF', with: numero_allocataire
|
||||
fill_in 'Le code postal', with: 'wrong_code'
|
||||
|
||||
blur
|
||||
expect(page).to have_css('span', text: 'Brouillon enregistré', visible: true)
|
||||
|
||||
dossier = Dossier.last
|
||||
expect(dossier.champs.first.code_postal).to eq('wrong_code')
|
||||
|
||||
click_on 'Déposer le dossier'
|
||||
expect(page).to have_content(/code postal doit posséder 5 caractères/)
|
||||
|
||||
fill_in 'Le code postal', with: code_postal
|
||||
|
||||
VCR.use_cassette("api_particulier/success/composition_familiale") do
|
||||
perform_enqueued_jobs { click_on 'Déposer le dossier' }
|
||||
end
|
||||
|
||||
dossier = Dossier.last
|
||||
|
||||
visit demande_dossier_path(dossier)
|
||||
expect(page).to have_content(/Des données.*ont été reçues depuis la CAF/)
|
||||
|
||||
|
|
|
@ -38,8 +38,9 @@ describe Champs::CnafChamp, type: :model do
|
|||
let(:numero_allocataire) { '1234567' }
|
||||
let(:code_postal) { '12345' }
|
||||
let(:champ) { described_class.new(dossier: create(:dossier), type_de_champ: create(:type_de_champ_cnaf)) }
|
||||
let(:validation_context) { :create }
|
||||
|
||||
subject { champ.valid? }
|
||||
subject { champ.valid?(validation_context) }
|
||||
|
||||
before do
|
||||
champ.numero_allocataire = numero_allocataire
|
||||
|
@ -82,6 +83,12 @@ describe Champs::CnafChamp, type: :model do
|
|||
is_expected.to be false
|
||||
expect(champ.errors.full_messages).to eq(["Numero allocataire doit être composé au maximum de 7 chiffres"])
|
||||
end
|
||||
|
||||
context 'and the validation_context is :brouillon' do
|
||||
let(:validation_context) { :brouillon }
|
||||
|
||||
it { is_expected.to be true }
|
||||
end
|
||||
end
|
||||
|
||||
context 'when code_postal is invalid' do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue