2017-01-24 14:36:43 +01:00
|
|
|
describe Admin::MailTemplatesController, type: :controller do
|
2017-03-05 11:05:28 +01:00
|
|
|
let(:procedure) { create :procedure }
|
2017-12-22 21:37:08 +01:00
|
|
|
let(:initiated_mail) { Mails::InitiatedMail.default_for_procedure(procedure) }
|
2017-01-24 14:36:43 +01:00
|
|
|
|
|
|
|
before do
|
2019-08-09 10:46:39 +02:00
|
|
|
sign_in(procedure.administrateurs.first.user)
|
2017-01-24 14:36:43 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'PATCH update' do
|
2018-01-08 17:26:13 +01:00
|
|
|
let(:mail_subject) { 'plop modif' }
|
|
|
|
let(:mail_body) { 'plip modif' }
|
2017-01-24 14:36:43 +01:00
|
|
|
|
2017-03-05 11:05:28 +01:00
|
|
|
before :each do
|
|
|
|
patch :update,
|
2018-01-15 15:34:26 +01:00
|
|
|
params: {
|
|
|
|
procedure_id: procedure.id,
|
|
|
|
id: initiated_mail.class.const_get(:SLUG),
|
|
|
|
mail_template: { subject: mail_subject, body: mail_body }
|
|
|
|
}
|
2017-03-05 11:05:28 +01:00
|
|
|
end
|
|
|
|
|
2019-03-21 15:05:30 +01:00
|
|
|
it { expect(response).to redirect_to edit_admin_procedure_mail_template_path(procedure, initiated_mail.class.const_get(:SLUG)) }
|
2017-03-05 11:05:28 +01:00
|
|
|
|
|
|
|
context 'the mail template' do
|
2018-01-15 21:52:21 +01:00
|
|
|
subject { procedure.reload; procedure.initiated_mail_template }
|
2017-03-05 11:05:28 +01:00
|
|
|
|
2018-01-08 17:26:13 +01:00
|
|
|
it { expect(subject.subject).to eq(mail_subject) }
|
|
|
|
it { expect(subject.body).to eq(mail_body) }
|
2017-01-24 14:36:43 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|