admin: display CTA buttons in emails preview
This commit is contained in:
parent
1c837eb901
commit
2174172e34
3 changed files with 24 additions and 14 deletions
|
@ -3,12 +3,14 @@ module NewAdministrateur
|
|||
include ActionView::Helpers::SanitizeHelper
|
||||
|
||||
def preview
|
||||
@procedure = procedure
|
||||
mail_template = find_mail_template_by_slug(params[:id])
|
||||
dossier = Dossier.new(id: '1', procedure: procedure)
|
||||
|
||||
@dossier = dossier
|
||||
@logo_url = procedure.logo.url
|
||||
@service = procedure.service
|
||||
|
||||
mail_template = find_mail_template_by_slug(params[:id])
|
||||
@rendered_template = sanitize(mail_template.body)
|
||||
@actions = mail_template.actions_for_dossier(dossier)
|
||||
|
||||
render(template: 'notification_mailer/send_notification', layout: 'mailers/notifications_layout')
|
||||
end
|
||||
|
@ -16,16 +18,16 @@ module NewAdministrateur
|
|||
private
|
||||
|
||||
def procedure
|
||||
@procedure = current_administrateur.procedures.find(params[:procedure_id])
|
||||
@procedure ||= current_administrateur.procedures.find(params[:procedure_id])
|
||||
end
|
||||
|
||||
def mail_templates
|
||||
[
|
||||
@procedure.initiated_mail_template,
|
||||
@procedure.received_mail_template,
|
||||
@procedure.closed_mail_template,
|
||||
@procedure.refused_mail_template,
|
||||
@procedure.without_continuation_mail_template
|
||||
procedure.initiated_mail_template,
|
||||
procedure.received_mail_template,
|
||||
procedure.closed_mail_template,
|
||||
procedure.refused_mail_template,
|
||||
procedure.without_continuation_mail_template
|
||||
]
|
||||
end
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
= vertical_margin(15)
|
||||
= vertical_margin(12)
|
||||
|
||||
- actions.each_with_index do |action, index|
|
||||
- variant = (index == 0 ? :primary : :secondary)
|
||||
|
@ -10,4 +10,4 @@
|
|||
- when MailTemplateConcern::Actions::REPLY
|
||||
= round_button('Répondre à ce message', messagerie_dossier_url(@dossier), variant)
|
||||
|
||||
= vertical_margin(8)
|
||||
= vertical_margin(5)
|
||||
|
|
|
@ -13,9 +13,17 @@ describe NewAdministrateur::MailTemplatesController, type: :controller do
|
|||
|
||||
it { expect(response).to have_http_status(:ok) }
|
||||
|
||||
it { expect(response.body).to have_css("img[src*='#{procedure.logo.filename}']") }
|
||||
it 'displays the procedure logo' do
|
||||
expect(response.body).to have_css("img[src*='#{procedure.logo.filename}']")
|
||||
end
|
||||
|
||||
it { expect(response.body).to include(procedure.service.nom) }
|
||||
it { expect(response.body).to include(procedure.service.telephone) }
|
||||
it 'displays the action buttons' do
|
||||
expect(response.body).to have_link('Consulter mon dossier')
|
||||
end
|
||||
|
||||
it 'displays the service in the footer' do
|
||||
expect(response.body).to include(procedure.service.nom)
|
||||
expect(response.body).to include(procedure.service.telephone)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue