Merge pull request #4578 from betagouv/fix_add_instructeur_with_empty_mails
Corrige une erreur lors de l'affectation d'instructeur avec une adresse vide
This commit is contained in:
commit
a78e4dc584
2 changed files with 8 additions and 1 deletions
|
@ -49,7 +49,8 @@ module NewAdministrateur
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_instructeur
|
def add_instructeur
|
||||||
emails = params['emails'].map(&:strip).map(&:downcase)
|
emails = params['emails'].presence || []
|
||||||
|
emails = emails.map(&:strip).map(&:downcase)
|
||||||
|
|
||||||
correct_emails, bad_emails = emails
|
correct_emails, bad_emails = emails
|
||||||
.partition { |email| URI::MailTo::EMAIL_REGEXP.match?(email) }
|
.partition { |email| URI::MailTo::EMAIL_REGEXP.match?(email) }
|
||||||
|
|
|
@ -117,6 +117,12 @@ describe NewAdministrateur::GroupeInstructeursController, type: :controller do
|
||||||
it { expect(flash.alert).to be_present }
|
it { expect(flash.alert).to be_present }
|
||||||
it { expect(response).to redirect_to(procedure_groupe_instructeur_path(procedure, procedure.defaut_groupe_instructeur)) }
|
it { expect(response).to redirect_to(procedure_groupe_instructeur_path(procedure, procedure.defaut_groupe_instructeur)) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'of an empty string' do
|
||||||
|
let(:new_instructeur_emails) { '' }
|
||||||
|
|
||||||
|
it { expect(response).to redirect_to(procedure_groupe_instructeur_path(procedure, procedure.defaut_groupe_instructeur)) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#remove_instructeur' do
|
describe '#remove_instructeur' do
|
||||||
|
|
Loading…
Add table
Reference in a new issue