Merge pull request #5457 from betagouv/feat/3661

feat/3661 - Adapt configuration email view to the new UI
This commit is contained in:
Kara Diaby 2020-08-07 11:50:26 +02:00 committed by GitHub
commit 406a31fda9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 12 deletions

View file

@ -2,6 +2,10 @@ module NewAdministrateur
class MailTemplatesController < AdministrateurController
include ActionView::Helpers::SanitizeHelper
def index
@mail_templates = mail_templates
end
def preview
mail_template = find_mail_template_by_slug(params[:id])
dossier = Dossier.new(id: '1', procedure: procedure)

View file

@ -0,0 +1,13 @@
= render partial: 'new_administrateur/breadcrumbs',
locals: { steps: [link_to('Démarches', admin_procedures_path),
link_to("#{@procedure.libelle}", admin_procedure_path(@procedure)), "Configuration des emails"] }
.container
- @mail_templates.each do |mail_template|
.card
.flex.justify-between
%div
.card-title= mail_template.class.const_get(:DISPLAYED_NAME)
%p.notice= mail_template.class.const_get(:DISPLAYED_NAME) === 'Accusé de réception' ? 'Personnalisé' : 'Modèle standard'
%div
= link_to 'Modifier', edit_admin_procedure_mail_template_path(@procedure, mail_template.class.const_get(:SLUG)), class: 'button'

View file

@ -189,7 +189,7 @@ Rails.application.routes.draw do
delete :delete_notice
end
resources :mail_templates, only: [:index, :edit, :update]
resources :mail_templates, only: [:edit, :update]
put 'archive' => 'procedures#archive', as: :archive
get 'publish_validate' => 'procedures#publish_validate', as: :publish_validate
@ -394,7 +394,7 @@ Rails.application.routes.draw do
end
end
resources :mail_templates, only: [] do
resources :mail_templates, only: [:index] do
get 'preview', on: :member
end

View file

@ -6,16 +6,6 @@ describe Admin::MailTemplatesController, type: :controller do
sign_in(procedure.administrateurs.first.user)
end
describe 'GET index' do
render_views
subject { get :index, params: { procedure_id: procedure.id } }
it { expect(subject.status).to eq 200 }
it { expect(subject.body).to include("E-mails personnalisables") }
it { expect(subject.body).to include(Mails::InitiatedMail::DISPLAYED_NAME) }
end
describe 'PATCH update' do
let(:mail_subject) { 'plop modif' }
let(:mail_body) { 'plip modif' }

View file

@ -1,8 +1,24 @@
describe NewAdministrateur::MailTemplatesController, type: :controller do
render_views
let(:procedure) { create :procedure }
let(:initiated_mail) { Mails::InitiatedMail.default_for_procedure(procedure) }
let(:admin) { create(:administrateur) }
before do
sign_in(procedure.administrateurs.first.user)
end
describe 'GET index' do
render_views
subject { get :index, params: { procedure_id: procedure.id } }
it { expect(subject.status).to eq 200 }
it { expect(subject.body).to include("Configuration des emails") }
it { expect(subject.body).to include(Mails::InitiatedMail::DISPLAYED_NAME) }
end
describe '#preview' do
let(:procedure) { create(:procedure, :with_logo, :with_service, administrateur: admin) }