Merge pull request #8789 from demarches-simplifiees/fix-avis-yes-no

[fix] Je peux répondre NON à une demande d'avis
This commit is contained in:
Lisa Durand 2023-03-21 16:32:47 +00:00 committed by GitHub
commit aa1f65a54e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -43,7 +43,7 @@ class Avis < ApplicationRecord
validates :email, format: { with: Devise.email_regexp, message: "n'est pas valide" }, allow_nil: true
validates :claimant, presence: true
validates :question_answer, presence: { on: :update, if: -> { question_label.present? } }
validates :question_answer, inclusion: { in: [true, false] }, on: :update, if: -> { question_label.present? }
validates :piece_justificative_file, size: { less_than: FILE_MAX_SIZE }
validates :introduction_file, size: { less_than: FILE_MAX_SIZE }
before_validation -> { sanitize_email(:email) }

View file

@ -100,15 +100,15 @@ describe 'Inviting an expert:' do
# check validation
click_on 'Envoyer votre avis'
expect(page).to have_content('Le champ « Réponse oui/non » doit être rempli')
expect(page).to have_content("Le champ « Réponse oui/non » n'est pas inclus(e) dans la liste")
choose 'oui'
choose 'non'
fill_in 'avis_answer', with: 'Ma réponse dexpert.'
click_on 'Envoyer votre avis'
expect(page).to have_content('Votre réponse est enregistrée')
expect(page).to have_content('Ma réponse dexpert.')
expect(page).to have_content('oui')
expect(page).to have_content('non')
within('.breadcrumbs') { click_on 'Avis' }
expect(page).to have_text('1 avis donné')