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:
commit
34343c6685
2 changed files with 10 additions and 1 deletions
|
@ -3,7 +3,7 @@ class InvitesController < ApplicationController
|
|||
before_action :store_user_location!, only: [:show]
|
||||
|
||||
def create
|
||||
email = params[:invite_email].downcase
|
||||
email = params[:invite_email]&.downcase
|
||||
@dossier = current_user.dossiers.visible_by_user.find(params[:dossier_id])
|
||||
invite = Invite.create(
|
||||
dossier: @dossier,
|
||||
|
|
|
@ -121,6 +121,15 @@ describe InvitesController, type: :controller do
|
|||
it { expect(flash[:alert]).to be_present }
|
||||
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
|
||||
let!(:invite) { create(:invite, dossier: dossier) }
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue