[Fix #667] Can add an already register gestionnaire with uppercase email

This commit is contained in:
Simon Lehericey 2017-08-28 15:36:34 +02:00
parent 8ff275659b
commit 806c41af38
2 changed files with 18 additions and 1 deletions

View file

@ -12,7 +12,8 @@ class Admin::GestionnairesController < AdminController
end
def create
@gestionnaire = Gestionnaire.find_by_email(params[:gestionnaire][:email])
email = params[:gestionnaire][:email].downcase
@gestionnaire = Gestionnaire.find_by_email(email)
procedure_id = params[:procedure_id]
if @gestionnaire.nil?

View file

@ -119,6 +119,22 @@ describe Admin::GestionnairesController, type: :controller do
it { expect(gestionnaire.administrateurs.size).to eq 2 }
end
context 'when an other admin will add the same email with some uppercase in it' do
let(:email) { 'Test@Plop.com' }
let(:gestionnaire) { Gestionnaire.find_by_email(email.downcase) }
before do
create :gestionnaire, email: email, administrateurs: [admin]
sign_out admin
sign_in admin_2
subject
end
it { expect(admin_2.gestionnaires).to include gestionnaire }
end
context 'Email notification' do
it 'Notification email is sent when accompagnateur is create' do
expect(GestionnaireMailer).to receive(:new_gestionnaire).and_return(GestionnaireMailer)