[Fix #1931] User can ask support to delete dossier

This commit is contained in:
Mathieu Magnin 2018-05-24 15:55:47 +02:00
parent 4cb9fe05e5
commit aaf1bc0b99
6 changed files with 63 additions and 0 deletions

View file

@ -384,4 +384,33 @@ describe NewUser::DossiersController, type: :controller do
end
end
end
describe '#ask_deletion' do
before { sign_in(user) }
subject { post :ask_deletion, params: { id: dossier.id } }
context 'when dossier is owned by signed in user' do
let(:dossier) { create(:dossier, user: user, autorisation_donnees: true) }
it do
expect(DossierMailer).to receive(:ask_deletion).and_return(double(deliver_later: nil))
subject
end
it { is_expected.to redirect_to(users_dossier_recapitulatif_path(dossier)) }
end
context 'when dossier is not owned by signed in user' do
let(:user2) { create(:user) }
let(:dossier) { create(:dossier, user: user2, autorisation_donnees: true) }
it do
expect(DossierMailer).not_to receive(:ask_deletion)
subject
end
it { is_expected.to redirect_to(root_path) }
end
end
end