Merge pull request #669 from sgmap/fix_667_gestionnaire_add_with_uppercase

[Fix #667] Can add an already register gestionnaire with uppercase email
This commit is contained in:
LeSim 2017-08-28 16:27:15 +02:00 committed by GitHub
commit fa395191f3
2 changed files with 18 additions and 1 deletions

View file

@ -12,7 +12,8 @@ class Admin::GestionnairesController < AdminController
end end
def create 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] procedure_id = params[:procedure_id]
if @gestionnaire.nil? if @gestionnaire.nil?

View file

@ -119,6 +119,22 @@ describe Admin::GestionnairesController, type: :controller do
it { expect(gestionnaire.administrateurs.size).to eq 2 } it { expect(gestionnaire.administrateurs.size).to eq 2 }
end 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 context 'Email notification' do
it 'Notification email is sent when accompagnateur is create' do it 'Notification email is sent when accompagnateur is create' do
expect(GestionnaireMailer).to receive(:new_gestionnaire).and_return(GestionnaireMailer) expect(GestionnaireMailer).to receive(:new_gestionnaire).and_return(GestionnaireMailer)