diff --git a/app/models/avis.rb b/app/models/avis.rb index cd8e7c532..8046edd2d 100644 --- a/app/models/avis.rb +++ b/app/models/avis.rb @@ -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) } diff --git a/spec/system/experts/expert_spec.rb b/spec/system/experts/expert_spec.rb index b78d1de56..9fe482596 100644 --- a/spec/system/experts/expert_spec.rb +++ b/spec/system/experts/expert_spec.rb @@ -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 d’expert.' click_on 'Envoyer votre avis' expect(page).to have_content('Votre réponse est enregistrée') expect(page).to have_content('Ma réponse d’expert.') - 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é')