fix specs
This commit is contained in:
parent
42633c0012
commit
7539d2ddea
5 changed files with 5 additions and 6 deletions
|
@ -9,7 +9,7 @@ module Administrateurs
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
emails = params['emails'].presence || [].to_json
|
emails = params['emails'].presence || []
|
||||||
|
|
||||||
emails = check_if_typo(emails)
|
emails = check_if_typo(emails)
|
||||||
errors = Array.wrap(generate_emails_suggestions_message(@maybe_typos))
|
errors = Array.wrap(generate_emails_suggestions_message(@maybe_typos))
|
||||||
|
|
|
@ -219,8 +219,7 @@ module Administrateurs
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_instructeur
|
def add_instructeur
|
||||||
emails = params['emails'].presence || [].to_json
|
emails = params['emails'].presence || []
|
||||||
|
|
||||||
emails = check_if_typo(emails)
|
emails = check_if_typo(emails)
|
||||||
errors = Array.wrap(generate_emails_suggestions_message(@maybe_typos))
|
errors = Array.wrap(generate_emails_suggestions_message(@maybe_typos))
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ module Instructeurs
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_instructeur
|
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
|
email = check_if_typo(email)&.first
|
||||||
errors = Array.wrap(generate_emails_suggestions_message(@maybe_typos))
|
errors = Array.wrap(generate_emails_suggestions_message(@maybe_typos))
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ module EmailSanitizableConcern
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_if_typo(emails)
|
def check_if_typo(emails)
|
||||||
emails = JSON.parse(emails).map { EmailSanitizer.sanitize(_1) }
|
emails = emails.map { EmailSanitizer.sanitize(_1) }
|
||||||
@maybe_typos, no_suggestions = emails
|
@maybe_typos, no_suggestions = emails
|
||||||
.map { |email| [email, EmailChecker.check(email:)[:suggestions]&.first] }
|
.map { |email| [email, EmailChecker.check(email:)[:suggestions]&.first] }
|
||||||
.partition { _1[1].present? }
|
.partition { _1[1].present? }
|
||||||
|
|
|
@ -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
|
context 'when the admin wants to assign an instructor who is already assigned on this procedure' do
|
||||||
let(:instructeur) { create(:instructeur) }
|
let(:instructeur) { create(:instructeur) }
|
||||||
before { procedure_non_routee.groupe_instructeurs.first.add_instructeurs(emails: [instructeur.user.email]) }
|
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) }
|
it { expect(subject).to render_template(:index) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue