Merge pull request #7633 from betagouv/7631-bug-invite

affiche un message d'alerte quand aucun email n'est donné pour une invitation sur un dossier
This commit is contained in:
krichtof 2022-07-27 15:09:07 +02:00 committed by GitHub
commit 34343c6685
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -3,7 +3,7 @@ class InvitesController < ApplicationController
before_action :store_user_location!, only: [:show] before_action :store_user_location!, only: [:show]
def create def create
email = params[:invite_email].downcase email = params[:invite_email]&.downcase
@dossier = current_user.dossiers.visible_by_user.find(params[:dossier_id]) @dossier = current_user.dossiers.visible_by_user.find(params[:dossier_id])
invite = Invite.create( invite = Invite.create(
dossier: @dossier, dossier: @dossier,

View file

@ -121,6 +121,15 @@ describe InvitesController, type: :controller do
it { expect(flash[:alert]).to be_present } it { expect(flash[:alert]).to be_present }
end end
context "when user does'nt give any email" do
subject { post :create, params: { dossier_id: dossier.id } }
before do
subject
end
it { expect { subject }.not_to change(Invite, :count) }
it { expect(flash[:alert]).to be_present }
end
context 'when email is already used' do context 'when email is already used' do
let!(:invite) { create(:invite, dossier: dossier) } let!(:invite) { create(:invite, dossier: dossier) }