fix specs

This commit is contained in:
Lisa Durand 2024-07-10 15:54:12 +02:00
parent 42633c0012
commit 7539d2ddea
No known key found for this signature in database
GPG key ID: 0DF91F2CA1E8B816
5 changed files with 5 additions and 6 deletions

View file

@ -9,7 +9,7 @@ module Administrateurs
end
def create
emails = params['emails'].presence || [].to_json
emails = params['emails'].presence || []
emails = check_if_typo(emails)
errors = Array.wrap(generate_emails_suggestions_message(@maybe_typos))

View file

@ -219,8 +219,7 @@ module Administrateurs
end
def add_instructeur
emails = params['emails'].presence || [].to_json
emails = params['emails'].presence || []
emails = check_if_typo(emails)
errors = Array.wrap(generate_emails_suggestions_message(@maybe_typos))

View file

@ -20,7 +20,7 @@ module Instructeurs
end
def add_instructeur
email = instructeur_email.present? ? [instructeur_email].to_json : [].to_json
email = instructeur_email.present? ? [instructeur_email] : []
email = check_if_typo(email)&.first
errors = Array.wrap(generate_emails_suggestions_message(@maybe_typos))

View file

@ -18,7 +18,7 @@ module EmailSanitizableConcern
end
def check_if_typo(emails)
emails = JSON.parse(emails).map { EmailSanitizer.sanitize(_1) }
emails = emails.map { EmailSanitizer.sanitize(_1) }
@maybe_typos, no_suggestions = emails
.map { |email| [email, EmailChecker.check(email:)[:suggestions]&.first] }
.partition { _1[1].present? }

View file

@ -359,7 +359,7 @@ describe Administrateurs::GroupeInstructeursController, type: :controller do
context 'when the admin wants to assign an instructor who is already assigned on this procedure' do
let(:instructeur) { create(:instructeur) }
before { procedure_non_routee.groupe_instructeurs.first.add_instructeurs(emails: [instructeur.user.email]) }
let(:emails) { [instructeur.email].to_json }
let(:emails) { [instructeur.email] }
it { expect(subject).to render_template(:index) }
end