2017-01-24 14:36:43 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
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
|
|
|
|
sign_in procedure.administrateur
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'GET index' do
|
|
|
|
render_views
|
|
|
|
|
2017-03-05 11:05:28 +01:00
|
|
|
subject { get :index, params: { procedure_id: procedure.id } }
|
2017-01-24 14:36:43 +01:00
|
|
|
|
|
|
|
it { expect(subject.status).to eq 200 }
|
|
|
|
it { expect(subject.body).to include("E-mails personnalisables") }
|
2017-03-06 23:18:16 +01:00
|
|
|
it { expect(subject.body).to include(Mails::InitiatedMail::DISPLAYED_NAME) }
|
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,
|
|
|
|
params: { procedure_id: procedure.id,
|
2017-05-27 00:52:32 +02:00
|
|
|
id: initiated_mail.class.const_get(:SLUG),
|
2018-01-08 17:26:13 +01:00
|
|
|
mail_template: { subject: mail_subject, body: mail_body }
|
2017-03-05 11:05:28 +01:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(response).to redirect_to admin_procedure_mail_templates_path(procedure) }
|
|
|
|
|
|
|
|
context 'the mail template' do
|
2017-05-27 01:08:01 +02: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
|