[Fix #667] Can add an already register gestionnaire with uppercase email
This commit is contained in:
parent
8ff275659b
commit
806c41af38
2 changed files with 18 additions and 1 deletions
|
@ -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?
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue