[#1563] Generate a helpful alert on attestation / closed mail mismatch
This commit is contained in:
parent
809638df79
commit
a2ffc4357d
2 changed files with 68 additions and 0 deletions
|
@ -0,0 +1,22 @@
|
|||
- case @procedure.closed_mail_template_attestation_inconsistency_state
|
||||
- when :missing_tag
|
||||
.center
|
||||
.alert{ class: flash_class('alert') }
|
||||
Cette procédure comporte une attestation, mais l’accusé d’acceptation ne la mentionne pas :
|
||||
- if !@procedure.locked?
|
||||
= link_to('désactivez l’attestation', edit_admin_procedure_attestation_template_path(@procedure))
|
||||
ou
|
||||
= link_to('ajoutez la balise', edit_admin_procedure_mail_template_path(@procedure, Mails::ClosedMail::SLUG))
|
||||
%code{ style: "white-space: pre-wrap;" }
|
||||
\--lien attestation--
|
||||
à l’accusé d’acceptation
|
||||
- when :extraneous_tag
|
||||
.center
|
||||
.alert{ class: flash_class('alert') }
|
||||
Cette procédure ne comporte pas d’attestation, mais l’accusé d’acceptation en mentionne une :
|
||||
= link_to('activez l’attestation', edit_admin_procedure_attestation_template_path(@procedure))
|
||||
ou
|
||||
= link_to('enlevez la balise', edit_admin_procedure_mail_template_path(@procedure, Mails::ClosedMail::SLUG))
|
||||
%code{ style: "white-space: pre-wrap;" }
|
||||
\--lien attestation--
|
||||
de l’accusé d’acceptation
|
|
@ -0,0 +1,46 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'admin/_closed_mail_template_attestation_inconsistency_alert.html.haml', type: :view do
|
||||
let(:procedure) { create(:procedure, closed_mail: closed_mail, published_at: published_at) }
|
||||
let(:published_at) { nil }
|
||||
|
||||
def alert
|
||||
assign(:procedure, procedure)
|
||||
render
|
||||
rendered
|
||||
end
|
||||
|
||||
context 'when there is no inconsistency' do
|
||||
let(:closed_mail) { nil }
|
||||
|
||||
it { expect(alert).to be_empty }
|
||||
end
|
||||
|
||||
context 'when there is no active attestation but the closed mail template mentions one' do
|
||||
let(:closed_mail) { create(:closed_mail, body: '--lien attestation--') }
|
||||
|
||||
it { expect(alert).to include("Cette procédure ne comporte pas d’attestation, mais l’accusé d’acceptation en mentionne une") }
|
||||
it { expect(alert).to include(edit_admin_procedure_attestation_template_path(procedure)) }
|
||||
it { expect(alert).to include(edit_admin_procedure_mail_template_path(procedure, Mails::ClosedMail::SLUG)) }
|
||||
end
|
||||
|
||||
context 'when there is an active attestation but the closed mail template does not mention it' do
|
||||
let(:closed_mail) { create(:closed_mail) }
|
||||
let!(:attestation_template) { create(:attestation_template, procedure: procedure, activated: true) }
|
||||
|
||||
it { expect(alert).to include("Cette procédure comporte une attestation, mais l’accusé d’acceptation ne la mentionne pas") }
|
||||
it { expect(alert).to include(edit_admin_procedure_mail_template_path(procedure, Mails::ClosedMail::SLUG)) }
|
||||
|
||||
context 'when the procedure has been published, the attestation cannot be deactivated' do
|
||||
let(:published_at) { Time.now }
|
||||
|
||||
it { expect(procedure.locked?).to be_truthy }
|
||||
it { expect(alert).not_to include(edit_admin_procedure_attestation_template_path(procedure)) }
|
||||
end
|
||||
|
||||
context 'when the procedure is still a draft' do
|
||||
it { expect(procedure.locked?).to be_falsey }
|
||||
it { expect(alert).to include(edit_admin_procedure_attestation_template_path(procedure)) }
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue