Send an email when user submitted his file

This commit is contained in:
Xavier J 2015-12-17 10:09:44 +01:00
parent ed8b4ff083
commit 44554a9baa
2 changed files with 12 additions and 1 deletions

View file

@ -29,6 +29,8 @@ class Users::RecapitulatifController < UsersController
@dossier.next_step! 'user', 'submit' @dossier.next_step! 'user', 'submit'
flash.notice = 'Dossier déposé avec succès.' flash.notice = 'Dossier déposé avec succès.'
NotificationMailer.dossier_submitted(@dossier).deliver_now!
render 'show' render 'show'
end end
end end

View file

@ -1,7 +1,7 @@
require 'spec_helper' require 'spec_helper'
describe Users::RecapitulatifController, type: :controller do describe Users::RecapitulatifController, type: :controller do
let(:dossier) { create(:dossier, :with_user) } let(:dossier) { create(:dossier, :with_user, :with_procedure) }
let(:bad_dossier_id) { Dossier.count + 100000 } let(:bad_dossier_id) { Dossier.count + 100000 }
before do before do
@ -55,6 +55,15 @@ describe Users::RecapitulatifController, type: :controller do
it 'a message informe user what his dossier is initiated' do it 'a message informe user what his dossier is initiated' do
expect(flash[:notice]).to include('Dossier déposé avec succès.') expect(flash[:notice]).to include('Dossier déposé avec succès.')
end end
it 'Notification email is send' do
expect(NotificationMailer).to receive(:dossier_submitted).and_return(NotificationMailer)
expect(NotificationMailer).to receive(:deliver_now!)
dossier.validated!
post :submit, dossier_id: dossier.id
end
end end
end end