Merge branch 'dev' into add-gestionnaires-to-procedures-manager
This commit is contained in:
commit
c49b88453f
3 changed files with 29 additions and 7 deletions
|
@ -17,7 +17,11 @@ class Users::RegistrationsController < Devise::RegistrationsController
|
|||
def create
|
||||
user = User.find_by(email: params[:user][:email])
|
||||
if user.present?
|
||||
UserMailer.new_account_warning(user).deliver_later
|
||||
if user.confirmed?
|
||||
UserMailer.new_account_warning(user).deliver_later
|
||||
else
|
||||
user.resend_confirmation_instructions
|
||||
end
|
||||
flash.notice = t('devise.registrations.signed_up_but_unconfirmed')
|
||||
redirect_to root_path
|
||||
else
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
%td= raison_sociale_or_name(etablissement)
|
||||
%tr
|
||||
%th.libelle SIRET :
|
||||
%td= etablissement.entreprise.siret_siege_social
|
||||
%td= etablissement.siret
|
||||
%tr
|
||||
%th.libelle Forme juridique :
|
||||
%td= sanitize(etablissement.entreprise.forme_juridique)
|
||||
|
|
|
@ -34,16 +34,34 @@ describe Users::RegistrationsController, type: :controller do
|
|||
end
|
||||
|
||||
context 'when the user already exists' do
|
||||
let!(:existing_user) { create(:user, email: email, password: password) }
|
||||
let!(:existing_user) { create(:user, email: email, password: password, confirmed_at: confirmed_at) }
|
||||
|
||||
before do
|
||||
allow(UserMailer).to receive(:new_account_warning).and_return(double(deliver_later: 'deliver'))
|
||||
subject
|
||||
end
|
||||
|
||||
it { expect(response).to redirect_to(root_path) }
|
||||
it { expect(flash.notice).to eq(I18n.t('devise.registrations.signed_up_but_unconfirmed')) }
|
||||
it { expect(UserMailer).to have_received(:new_account_warning) }
|
||||
context 'and the user is confirmed' do
|
||||
let(:confirmed_at) { DateTime.now }
|
||||
|
||||
before { subject }
|
||||
|
||||
it { expect(response).to redirect_to(root_path) }
|
||||
it { expect(flash.notice).to eq(I18n.t('devise.registrations.signed_up_but_unconfirmed')) }
|
||||
it { expect(UserMailer).to have_received(:new_account_warning) }
|
||||
end
|
||||
|
||||
context 'and the user is not confirmed' do
|
||||
let(:confirmed_at) { nil }
|
||||
|
||||
before do
|
||||
expect_any_instance_of(User).to receive(:resend_confirmation_instructions)
|
||||
subject
|
||||
end
|
||||
|
||||
it { expect(response).to redirect_to(root_path) }
|
||||
it { expect(flash.notice).to eq(I18n.t('devise.registrations.signed_up_but_unconfirmed')) }
|
||||
it { expect(UserMailer).not_to have_received(:new_account_warning) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue