refactor(attestation_template): move to procedure
This commit is contained in:
parent
55c5de2c2c
commit
cafda4f6f0
20 changed files with 170 additions and 249 deletions
|
@ -1,7 +1,7 @@
|
||||||
.fr-col-6.fr-col-md-4.fr-col-lg-3
|
.fr-col-6.fr-col-md-4.fr-col-lg-3
|
||||||
= link_to edit_admin_procedure_attestation_template_path(@procedure), class: 'fr-tile fr-enlarge-link' do
|
= link_to edit_admin_procedure_attestation_template_path(@procedure), class: 'fr-tile fr-enlarge-link' do
|
||||||
.fr-tile__body.flex.justify-between
|
.fr-tile__body.flex.justify-between
|
||||||
- if @procedure.draft_attestation_template&.activated?
|
- if @procedure.attestation_template&.activated?
|
||||||
%div
|
%div
|
||||||
%span.icon.accept
|
%span.icon.accept
|
||||||
%p.fr-tile-status-accept Activée
|
%p.fr-tile-status-accept Activée
|
||||||
|
|
|
@ -2,53 +2,56 @@ module Administrateurs
|
||||||
class AttestationTemplatesController < AdministrateurController
|
class AttestationTemplatesController < AdministrateurController
|
||||||
before_action :retrieve_procedure
|
before_action :retrieve_procedure
|
||||||
|
|
||||||
|
def show
|
||||||
|
redirect_to edit_admin_procedure_attestation_template_path(@procedure)
|
||||||
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@attestation_template = build_attestation
|
@attestation_template = build_attestation_template
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
attestation_template = @procedure.draft_attestation_template.find_or_revise!
|
@procedure.move_attestation_template_to_procedure!
|
||||||
|
|
||||||
if attestation_template.update(activated_attestation_params)
|
@attestation_template = @procedure.attestation_template
|
||||||
AttestationTemplate
|
|
||||||
.where(id: @procedure.revisions.pluck(:attestation_template_id).compact)
|
|
||||||
.update_all(activated: attestation_template.activated?)
|
|
||||||
|
|
||||||
flash.notice = "L'attestation a bien été modifiée"
|
if @attestation_template.update(activated_attestation_params)
|
||||||
else
|
flash.notice = "Le model de l’attestation a bien été modifiée"
|
||||||
flash.alert = attestation_template.errors.full_messages.join('<br>')
|
|
||||||
end
|
|
||||||
|
|
||||||
redirect_to edit_admin_procedure_attestation_template_path(@procedure)
|
redirect_to edit_admin_procedure_attestation_template_path(@procedure)
|
||||||
|
else
|
||||||
|
flash.now.alert = @attestation_template.errors.full_messages
|
||||||
|
|
||||||
|
render :edit
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
attestation_template = build_attestation(activated_attestation_params)
|
@procedure.move_attestation_template_to_procedure!
|
||||||
|
|
||||||
if attestation_template.save
|
@attestation_template = build_attestation_template(activated_attestation_params)
|
||||||
if @procedure.publiee? && !@procedure.feature_enabled?(:procedure_revisions)
|
|
||||||
# If revisions support is not enabled and procedure is published
|
if @attestation_template.save
|
||||||
# attach the same attestation template to published revision.
|
flash.notice = "Le model de l’attestation a bien été enregistrée"
|
||||||
@procedure.published_revision.update(attestation_template: attestation_template)
|
|
||||||
end
|
|
||||||
flash.notice = "L'attestation a bien été sauvegardée"
|
|
||||||
else
|
|
||||||
flash.alert = attestation_template.errors.full_messages.join('<br>')
|
|
||||||
end
|
|
||||||
|
|
||||||
redirect_to edit_admin_procedure_attestation_template_path(@procedure)
|
redirect_to edit_admin_procedure_attestation_template_path(@procedure)
|
||||||
|
else
|
||||||
|
flash.now.alert = @attestation_template.errors.full_messages
|
||||||
|
|
||||||
|
render :edit
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def preview
|
def preview
|
||||||
@attestation = build_attestation.render_attributes_for({})
|
@attestation = build_attestation_template.render_attributes_for({})
|
||||||
|
|
||||||
render 'administrateurs/attestation_templates/show', formats: [:pdf]
|
render 'administrateurs/attestation_templates/show', formats: [:pdf]
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def build_attestation(attributes = {})
|
def build_attestation_template(attributes = {})
|
||||||
attestation_template = @procedure.draft_attestation_template || @procedure.draft_revision.build_attestation_template
|
attestation_template = @procedure.attestation_template || @procedure.build_attestation_template
|
||||||
attestation_template.attributes = attributes
|
attestation_template.attributes = attributes
|
||||||
attestation_template
|
attestation_template
|
||||||
end
|
end
|
||||||
|
|
|
@ -157,7 +157,7 @@ module Types
|
||||||
end
|
end
|
||||||
|
|
||||||
def attestation
|
def attestation
|
||||||
if object.attestation_activated?
|
if object.termine? && object.attestation_template&.activated?
|
||||||
Loaders::Association.for(object.class, attestation: { pdf_attachment: :blob })
|
Loaders::Association.for(object.class, attestation: { pdf_attachment: :blob })
|
||||||
.load(object)
|
.load(object)
|
||||||
.then { |attestation| attestation&.pdf }
|
.then { |attestation| attestation&.pdf }
|
||||||
|
|
|
@ -15,6 +15,7 @@ class AttestationTemplate < ApplicationRecord
|
||||||
include ActionView::Helpers::NumberHelper
|
include ActionView::Helpers::NumberHelper
|
||||||
include TagsSubstitutionConcern
|
include TagsSubstitutionConcern
|
||||||
|
|
||||||
|
belongs_to :procedure, inverse_of: :attestation_template
|
||||||
has_many :revisions, class_name: 'ProcedureRevision', inverse_of: :attestation_template, dependent: :nullify
|
has_many :revisions, class_name: 'ProcedureRevision', inverse_of: :attestation_template, dependent: :nullify
|
||||||
|
|
||||||
has_one_attached :logo
|
has_one_attached :logo
|
||||||
|
@ -83,25 +84,8 @@ class AttestationTemplate < ApplicationRecord
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_or_revise!
|
|
||||||
if revisions.size > 1 && procedure.feature_enabled?(:procedure_revisions)
|
|
||||||
# If attestation template belongs to more then one revision
|
|
||||||
# and procedure has revisions enabled – revise attestation template.
|
|
||||||
attestation_template = dup
|
|
||||||
attestation_template.save!
|
|
||||||
procedure.draft_revision.update!(attestation_template: attestation_template)
|
|
||||||
attestation_template
|
|
||||||
else
|
|
||||||
# If procedure has only one revision or revisions are not supported
|
|
||||||
# apply updates directly to the attestation template.
|
|
||||||
# If it is a published procedure with revisions disabled,
|
|
||||||
# draft and published attestation template will be the same.
|
|
||||||
self
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def procedure
|
def procedure
|
||||||
revisions.last&.procedure
|
super || revisions.last&.procedure
|
||||||
end
|
end
|
||||||
|
|
||||||
def logo_checksum
|
def logo_checksum
|
||||||
|
|
|
@ -135,8 +135,8 @@ class Dossier < ApplicationRecord
|
||||||
|
|
||||||
has_one :france_connect_information, through: :user
|
has_one :france_connect_information, through: :user
|
||||||
|
|
||||||
has_one :attestation_template, through: :revision
|
|
||||||
has_one :procedure, through: :revision
|
has_one :procedure, through: :revision
|
||||||
|
has_one :attestation_template, through: :procedure
|
||||||
has_many :types_de_champ, through: :revision, source: :types_de_champ_public
|
has_many :types_de_champ, through: :revision, source: :types_de_champ_public
|
||||||
has_many :types_de_champ_private, through: :revision
|
has_many :types_de_champ_private, through: :revision
|
||||||
|
|
||||||
|
@ -375,7 +375,7 @@ class Dossier < ApplicationRecord
|
||||||
.where.not(user: users_who_submitted)
|
.where.not(user: users_who_submitted)
|
||||||
end
|
end
|
||||||
|
|
||||||
scope :for_api_v2, -> { includes(revision: [:attestation_template, procedure: [:administrateurs]], etablissement: [], individual: [], traitement: []) }
|
scope :for_api_v2, -> { includes(:attestation_template, revision: [procedure: [:administrateurs]], etablissement: [], individual: [], traitement: []) }
|
||||||
|
|
||||||
scope :with_notifications, -> do
|
scope :with_notifications, -> do
|
||||||
joins(:follows)
|
joins(:follows)
|
||||||
|
@ -748,17 +748,21 @@ class Dossier < ApplicationRecord
|
||||||
{ lon: lon, lat: lat, zoom: zoom }
|
{ lon: lon, lat: lat, zoom: zoom }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def active_attestation_template
|
||||||
|
attestation_template || revision.attestation_template
|
||||||
|
end
|
||||||
|
|
||||||
def unspecified_attestation_champs
|
def unspecified_attestation_champs
|
||||||
if attestation_template&.activated?
|
if active_attestation_template&.activated?
|
||||||
attestation_template.unspecified_champs_for_dossier(self)
|
active_attestation_template.unspecified_champs_for_dossier(self)
|
||||||
else
|
else
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_attestation
|
def build_attestation
|
||||||
if attestation_template&.activated?
|
if active_attestation_template&.activated?
|
||||||
attestation_template.attestation_for(self)
|
active_attestation_template.attestation_for(self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -819,10 +823,6 @@ class Dossier < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def attestation_activated?
|
|
||||||
termine? && attestation_template&.activated?
|
|
||||||
end
|
|
||||||
|
|
||||||
def after_passer_en_construction
|
def after_passer_en_construction
|
||||||
self.conservation_extension = 0.days
|
self.conservation_extension = 0.days
|
||||||
self.depose_at = self.en_construction_at = self.traitements
|
self.depose_at = self.en_construction_at = self.traitements
|
||||||
|
|
|
@ -81,7 +81,6 @@ class Procedure < ApplicationRecord
|
||||||
has_many :published_types_de_champ_private, through: :published_revision, source: :types_de_champ_private
|
has_many :published_types_de_champ_private, through: :published_revision, source: :types_de_champ_private
|
||||||
|
|
||||||
has_one :draft_attestation_template, through: :draft_revision, source: :attestation_template
|
has_one :draft_attestation_template, through: :draft_revision, source: :attestation_template
|
||||||
has_one :published_attestation_template, through: :published_revision, source: :attestation_template
|
|
||||||
|
|
||||||
has_one :published_dossier_submitted_message, dependent: :destroy, through: :published_revision, source: :dossier_submitted_message
|
has_one :published_dossier_submitted_message, dependent: :destroy, through: :published_revision, source: :dossier_submitted_message
|
||||||
has_one :draft_dossier_submitted_message, dependent: :destroy, through: :draft_revision, source: :dossier_submitted_message
|
has_one :draft_dossier_submitted_message, dependent: :destroy, through: :draft_revision, source: :dossier_submitted_message
|
||||||
|
@ -93,8 +92,7 @@ class Procedure < ApplicationRecord
|
||||||
foreign_key: "replaced_by_procedure_id", dependent: :nullify
|
foreign_key: "replaced_by_procedure_id", dependent: :nullify
|
||||||
|
|
||||||
has_one :module_api_carto, dependent: :destroy
|
has_one :module_api_carto, dependent: :destroy
|
||||||
has_one :legacy_attestation_template, class_name: 'AttestationTemplate', dependent: :destroy
|
has_one :attestation_template, dependent: :destroy
|
||||||
has_many :attestation_templates, through: :revisions, source: :attestation_template
|
|
||||||
|
|
||||||
belongs_to :parent_procedure, class_name: 'Procedure', optional: true
|
belongs_to :parent_procedure, class_name: 'Procedure', optional: true
|
||||||
belongs_to :canonical_procedure, class_name: 'Procedure', optional: true
|
belongs_to :canonical_procedure, class_name: 'Procedure', optional: true
|
||||||
|
@ -473,9 +471,9 @@ class Procedure < ApplicationRecord
|
||||||
|
|
||||||
populate_champ_stable_ids
|
populate_champ_stable_ids
|
||||||
include_list = {
|
include_list = {
|
||||||
|
attestation_template: [],
|
||||||
draft_revision: {
|
draft_revision: {
|
||||||
revision_types_de_champ: [:type_de_champ],
|
revision_types_de_champ: [:type_de_champ],
|
||||||
attestation_template: [],
|
|
||||||
dossier_submitted_message: []
|
dossier_submitted_message: []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -595,8 +593,11 @@ class Procedure < ApplicationRecord
|
||||||
touch(:whitelisted_at)
|
touch(:whitelisted_at)
|
||||||
end
|
end
|
||||||
|
|
||||||
def attestation_template
|
def move_attestation_template_to_procedure!
|
||||||
published_attestation_template || draft_attestation_template
|
if draft_attestation_template.present? && draft_attestation_template != attestation_template
|
||||||
|
draft_attestation_template.update_column(:procedure_id, id)
|
||||||
|
reload
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def closed_mail_template_attestation_inconsistency_state
|
def closed_mail_template_attestation_inconsistency_state
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
.procedure-form#attestation-template-edit
|
.procedure-form#attestation-template-edit
|
||||||
.procedure-form__columns.container
|
.procedure-form__columns.container
|
||||||
= form_for @attestation_template,
|
= form_for @attestation_template,
|
||||||
url: url_for({ controller: 'administrateurs/attestation_templates', action: :update, id: @procedure.id }),
|
url: admin_procedure_attestation_template_path(@procedure),
|
||||||
multipart: true,
|
multipart: true,
|
||||||
html: { class: 'form procedure-form__column--form' } do |f|
|
html: { class: 'form procedure-form__column--form' } do |f|
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
= form_tag(terminer_instructeur_dossier_path(dossier.procedure, dossier), data: { turbo: true, turbo_confirm: confirm }, method: :post, multipart: true, class: 'form') do
|
= form_tag(terminer_instructeur_dossier_path(dossier.procedure, dossier), data: { turbo: true, turbo_confirm: confirm }, method: :post, multipart: true, class: 'form') do
|
||||||
- if title == 'Accepter'
|
- if title == 'Accepter'
|
||||||
= text_area :dossier, :motivation, class: 'motivation-text-area', placeholder: placeholder, required: false
|
= text_area :dossier, :motivation, class: 'motivation-text-area', placeholder: placeholder, required: false
|
||||||
- if dossier.procedure.attestation_template&.activated?
|
- if dossier.attestation_template&.activated?
|
||||||
%p.help
|
%p.help
|
||||||
L’acceptation du dossier envoie automatiquement
|
L’acceptation du dossier envoie automatiquement
|
||||||
= link_to 'une attestation', apercu_attestation_instructeur_dossier_path(dossier.procedure, dossier), target: '_blank', rel: 'noopener', title: "Voir l'attestation qui sera envoyée à l'usager"
|
= link_to 'une attestation', apercu_attestation_instructeur_dossier_path(dossier.procedure, dossier), target: '_blank', rel: 'noopener', title: "Voir l'attestation qui sera envoyée à l'usager"
|
||||||
|
|
|
@ -7,7 +7,7 @@ fr:
|
||||||
title:
|
title:
|
||||||
format: Le titre du modèle de l’attestation %{message}
|
format: Le titre du modèle de l’attestation %{message}
|
||||||
champ_missing: réfère au champ "%{tag}" qui n’existe pas
|
champ_missing: réfère au champ "%{tag}" qui n’existe pas
|
||||||
champ_missing_in_draft_revision: réfère au champ "%{tag}" qui à été supprimé mais la suppression n’est pas encore publiée
|
champ_missing_in_draft_revision: réfère au champ "%{tag}" qui a été supprimé mais la suppression n’est pas encore publiée
|
||||||
champ_missing_in_published_revision: réfère au champ "%{tag}" qui n’est pas encore publié
|
champ_missing_in_published_revision: réfère au champ "%{tag}" qui n’est pas encore publié
|
||||||
champ_missing_in_published_and_draft_revision: réfère au champ "%{tag}" qui a été supprimé
|
champ_missing_in_published_and_draft_revision: réfère au champ "%{tag}" qui a été supprimé
|
||||||
champ_missing_in_previous_revision: réfère au champ "%{tag}" qui n’existe pas sur un des dossiers en cours de traitement
|
champ_missing_in_previous_revision: réfère au champ "%{tag}" qui n’existe pas sur un des dossiers en cours de traitement
|
||||||
|
|
|
@ -507,7 +507,7 @@ Rails.application.routes.draw do
|
||||||
get 'preview', on: :member
|
get 'preview', on: :member
|
||||||
end
|
end
|
||||||
|
|
||||||
resource :attestation_template, only: [:edit, :update, :create] do
|
resource :attestation_template, only: [:show, :edit, :update, :create] do
|
||||||
get 'preview', on: :member
|
get 'preview', on: :member
|
||||||
end
|
end
|
||||||
resource :dossier_submitted_message, only: [:edit, :update, :create]
|
resource :dossier_submitted_message, only: [:edit, :update, :create]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
describe Administrateurs::AttestationTemplatesController, type: :controller do
|
describe Administrateurs::AttestationTemplatesController, type: :controller do
|
||||||
let(:admin) { create(:administrateur) }
|
let(:admin) { create(:administrateur) }
|
||||||
let(:attestation_template) { build(:attestation_template) }
|
let(:attestation_template) { build(:attestation_template) }
|
||||||
let(:procedure) { create :procedure, administrateur: admin, attestation_template: attestation_template }
|
let(:procedure) { create(:procedure, administrateur: admin, attestation_template: attestation_template) }
|
||||||
let(:logo) { fixture_file_upload('spec/fixtures/files/white.png', 'image/png') }
|
let(:logo) { fixture_file_upload('spec/fixtures/files/white.png', 'image/png') }
|
||||||
let(:logo2) { fixture_file_upload('spec/fixtures/files/white.png', 'image/png') }
|
let(:logo2) { fixture_file_upload('spec/fixtures/files/white.png', 'image/png') }
|
||||||
let(:signature) { fixture_file_upload('spec/fixtures/files/black.png', 'image/png') }
|
let(:signature) { fixture_file_upload('spec/fixtures/files/black.png', 'image/png') }
|
||||||
|
@ -36,48 +36,41 @@ describe Administrateurs::AttestationTemplatesController, type: :controller do
|
||||||
params: {
|
params: {
|
||||||
procedure_id: procedure.id
|
procedure_id: procedure.id
|
||||||
}
|
}
|
||||||
procedure.reload
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'if an attestation template exists on the procedure' do
|
context 'if an attestation template exists on the procedure' do
|
||||||
after { procedure.draft_revision.attestation_template&.destroy }
|
|
||||||
|
|
||||||
context 'with images' do
|
context 'with images' do
|
||||||
let!(:attestation_template) do
|
let(:attestation_template) { build(:attestation_template, attestation_params.merge(logo: logo, signature: signature)) }
|
||||||
create(:attestation_template, attestation_params.merge(logo: logo, signature: signature))
|
|
||||||
end
|
|
||||||
|
|
||||||
it { expect(assigns(:attestation)).to include(attestation_params) }
|
it do
|
||||||
it { expect(assigns(:attestation)[:created_at]).to eq(Time.zone.now) }
|
expect(assigns(:attestation)).to include(attestation_params)
|
||||||
it { expect(assigns(:attestation)[:logo].download).to eq(logo2.read) }
|
expect(assigns(:attestation)[:created_at]).to eq(Time.zone.now)
|
||||||
it { expect(assigns(:attestation)[:signature].download).to eq(signature2.read) }
|
expect(assigns(:attestation)[:logo].download).to eq(logo2.read)
|
||||||
|
expect(assigns(:attestation)[:signature].download).to eq(signature2.read)
|
||||||
|
end
|
||||||
it_behaves_like 'rendering a PDF successfully'
|
it_behaves_like 'rendering a PDF successfully'
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'without images' do
|
context 'without images' do
|
||||||
let!(:attestation_template) do
|
let(:attestation_template) { build(:attestation_template, attestation_params) }
|
||||||
create(:attestation_template, attestation_params)
|
|
||||||
end
|
|
||||||
|
|
||||||
it { expect(assigns(:attestation)).to include(attestation_params) }
|
it do
|
||||||
it { expect(assigns(:attestation)[:created_at]).to eq(Time.zone.now) }
|
expect(assigns(:attestation)).to include(attestation_params)
|
||||||
it { expect(assigns(:attestation)[:logo]).to eq(nil) }
|
expect(assigns(:attestation)[:created_at]).to eq(Time.zone.now)
|
||||||
it { expect(assigns(:attestation)[:signature]).to eq(nil) }
|
expect(assigns(:attestation)[:logo]).to eq(nil)
|
||||||
|
expect(assigns(:attestation)[:signature]).to eq(nil)
|
||||||
|
end
|
||||||
it_behaves_like 'rendering a PDF successfully'
|
it_behaves_like 'rendering a PDF successfully'
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with empty footer' do
|
context 'with empty footer' do
|
||||||
let!(:attestation_template) do
|
let(:attestation_template) { build(:attestation_template, { title: 't', body: 'b', footer: nil }) }
|
||||||
create(:attestation_template, { title: 't', body: 'b', footer: nil })
|
|
||||||
end
|
|
||||||
|
|
||||||
it_behaves_like 'rendering a PDF successfully'
|
it_behaves_like 'rendering a PDF successfully'
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with large footer' do
|
context 'with large footer' do
|
||||||
let!(:attestation_params) do
|
let(:attestation_params) { build(:attestation_template, { title: 't', body: 'b', footer: ' ' * 190 }) }
|
||||||
create(:attestation_template, { title: 't', body: 'b', footer: ' ' * 190 })
|
|
||||||
end
|
|
||||||
|
|
||||||
it_behaves_like 'rendering a PDF successfully'
|
it_behaves_like 'rendering a PDF successfully'
|
||||||
end
|
end
|
||||||
|
@ -94,9 +87,12 @@ describe Administrateurs::AttestationTemplatesController, type: :controller do
|
||||||
|
|
||||||
context 'if an attestation template does not exist on the procedure' do
|
context 'if an attestation template does not exist on the procedure' do
|
||||||
let(:attestation_template) { nil }
|
let(:attestation_template) { nil }
|
||||||
it { expect(subject.status).to eq(200) }
|
|
||||||
it { expect(assigns(:attestation_template).id).to be_nil }
|
it do
|
||||||
it { expect(assigns(:attestation_template)).to be_an_instance_of(AttestationTemplate) }
|
expect(subject.status).to eq(200)
|
||||||
|
expect(assigns(:attestation_template).id).to be_nil
|
||||||
|
expect(assigns(:attestation_template)).to be_an_instance_of(AttestationTemplate)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -111,17 +107,16 @@ describe Administrateurs::AttestationTemplatesController, type: :controller do
|
||||||
procedure_id: procedure.id,
|
procedure_id: procedure.id,
|
||||||
attestation_template: attestation_params.merge(logo: logo, signature: signature)
|
attestation_template: attestation_params.merge(logo: logo, signature: signature)
|
||||||
}
|
}
|
||||||
procedure.reload
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(procedure.draft_attestation_template).to have_attributes(attestation_params) }
|
it do
|
||||||
it { expect(procedure.draft_attestation_template.activated).to be true }
|
expect(procedure.attestation_template).to have_attributes(attestation_params)
|
||||||
it { expect(procedure.draft_attestation_template.logo.download).to eq(logo2.read) }
|
expect(procedure.attestation_template.activated).to be true
|
||||||
it { expect(procedure.draft_attestation_template.signature.download).to eq(signature2.read) }
|
expect(procedure.attestation_template.logo.download).to eq(logo2.read)
|
||||||
it { expect(response).to redirect_to edit_admin_procedure_attestation_template_path(procedure) }
|
expect(procedure.attestation_template.signature.download).to eq(signature2.read)
|
||||||
it { expect(flash.notice).to eq("L'attestation a bien été sauvegardée") }
|
expect(response).to redirect_to edit_admin_procedure_attestation_template_path(procedure)
|
||||||
|
expect(flash.notice).to eq("Le model de l’attestation a bien été enregistrée")
|
||||||
after { procedure.draft_attestation_template.destroy }
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when something wrong happens in the attestation template creation' do
|
context 'when something wrong happens in the attestation template creation' do
|
||||||
|
@ -134,16 +129,16 @@ describe Administrateurs::AttestationTemplatesController, type: :controller do
|
||||||
procedure_id: procedure.id,
|
procedure_id: procedure.id,
|
||||||
attestation_template: attestation_params
|
attestation_template: attestation_params
|
||||||
}
|
}
|
||||||
procedure.reload
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(response).to redirect_to edit_admin_procedure_attestation_template_path(procedure) }
|
it do
|
||||||
it { expect(flash.alert).to be_present }
|
expect(flash.alert).to be_present
|
||||||
it { expect(procedure.draft_attestation_template).to be nil }
|
expect(procedure.draft_attestation_template).to be nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when procedure is published' do
|
context 'when procedure is published' do
|
||||||
let(:procedure) { create(:procedure, :published, administrateur: admin, attestation_template: attestation_template) }
|
let(:procedure) { create(:procedure, :published, administrateur: admin) }
|
||||||
let(:attestation_template) { nil }
|
let(:attestation_template) { nil }
|
||||||
let(:attestation_params) { { title: 't', body: 'b', footer: '', activated: true } }
|
let(:attestation_params) { { title: 't', body: 'b', footer: '', activated: true } }
|
||||||
let(:revisions_enabled) { false }
|
let(:revisions_enabled) { false }
|
||||||
|
@ -158,23 +153,11 @@ describe Administrateurs::AttestationTemplatesController, type: :controller do
|
||||||
procedure_id: procedure.id,
|
procedure_id: procedure.id,
|
||||||
attestation_template: attestation_params
|
attestation_template: attestation_params
|
||||||
}
|
}
|
||||||
procedure.reload
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'and revisions are not activated' do
|
|
||||||
it do
|
it do
|
||||||
expect(procedure.draft_attestation_template).to eq(procedure.published_attestation_template)
|
expect(procedure.attestation_template).to eq(procedure.attestation_template)
|
||||||
expect(procedure.draft_attestation_template.title).to eq('t')
|
expect(procedure.attestation_template.title).to eq('t')
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'and revisions are activated' do
|
|
||||||
let(:revisions_enabled) { true }
|
|
||||||
it do
|
|
||||||
expect(procedure.draft_attestation_template).not_to eq(procedure.published_attestation_template)
|
|
||||||
expect(procedure.draft_attestation_template.title).to eq('t')
|
|
||||||
expect(procedure.published_attestation_template).to be_nil
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -190,69 +173,93 @@ describe Administrateurs::AttestationTemplatesController, type: :controller do
|
||||||
procedure_id: procedure.id,
|
procedure_id: procedure.id,
|
||||||
attestation_template: attestation_params_with_images
|
attestation_template: attestation_params_with_images
|
||||||
}
|
}
|
||||||
procedure.reload
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(procedure.draft_attestation_template).to have_attributes(attestation_params) }
|
it do
|
||||||
it { expect(procedure.draft_attestation_template.logo.download).to eq(logo2.read) }
|
expect(procedure.attestation_template).to have_attributes(attestation_params)
|
||||||
it { expect(procedure.draft_attestation_template.signature.download).to eq(signature2.read) }
|
expect(procedure.attestation_template.logo.download).to eq(logo2.read)
|
||||||
it { expect(response).to redirect_to edit_admin_procedure_attestation_template_path(procedure) }
|
expect(procedure.attestation_template.signature.download).to eq(signature2.read)
|
||||||
it { expect(flash.notice).to eq("L'attestation a bien été modifiée") }
|
expect(response).to redirect_to edit_admin_procedure_attestation_template_path(procedure)
|
||||||
|
expect(flash.notice).to eq("Le model de l’attestation a bien été modifiée")
|
||||||
after { procedure.draft_attestation_template&.destroy }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when something wrong happens in the attestation template creation' do
|
|
||||||
before do
|
|
||||||
expect_any_instance_of(AttestationTemplate).to receive(:update).and_return(false)
|
|
||||||
expect_any_instance_of(AttestationTemplate).to receive(:errors)
|
|
||||||
.and_return(double(full_messages: ['nop']))
|
|
||||||
|
|
||||||
patch :update,
|
|
||||||
params: {
|
|
||||||
procedure_id: procedure.id,
|
|
||||||
attestation_template: attestation_params_with_images
|
|
||||||
}
|
|
||||||
procedure.reload
|
|
||||||
end
|
|
||||||
|
|
||||||
it { expect(response).to redirect_to edit_admin_procedure_attestation_template_path(procedure) }
|
|
||||||
it { expect(flash.alert).to eq('nop') }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when procedure is published' do
|
context 'when procedure is published' do
|
||||||
let(:procedure) { create(:procedure, :published, administrateur: admin, attestation_template: attestation_template) }
|
let(:procedure) { create(:procedure, :with_type_de_champ, types_de_champ_count: 3, administrateur: admin, attestation_template: attestation_template) }
|
||||||
let(:attestation_template) { create(:attestation_template, title: 'a') }
|
let(:dossier) {}
|
||||||
let(:attestation_params) { { title: 't', body: 'b', footer: '', activated: true } }
|
let(:attestation_template) { build(:attestation_template, title: 'a') }
|
||||||
let(:revisions_enabled) { false }
|
let(:attestation_params) do
|
||||||
|
{
|
||||||
|
title: title,
|
||||||
|
body: body,
|
||||||
|
footer: '',
|
||||||
|
activated: true
|
||||||
|
}
|
||||||
|
end
|
||||||
|
let(:type_de_champ) { procedure.draft_revision.types_de_champ_public[0] }
|
||||||
|
let(:removed_type_de_champ) { procedure.draft_revision.types_de_champ_public[1] }
|
||||||
|
let(:removed_and_published_type_de_champ) { procedure.draft_revision.types_de_champ_public[2] }
|
||||||
|
let(:new_type_de_champ) { procedure.draft_revision.types_de_champ_public.find_by(libelle: 'new type de champ') }
|
||||||
|
let(:draft_type_de_champ) { procedure.draft_revision.types_de_champ_public.find_by(libelle: 'draft type de champ') }
|
||||||
|
let(:title) { 'title --numéro du dossier--' }
|
||||||
|
let(:body) { "body --#{type_de_champ.libelle}-- et --#{new_type_de_champ.libelle}--" }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
if revisions_enabled
|
procedure.publish!
|
||||||
Flipper.enable(:procedure_revisions, procedure)
|
procedure.reload
|
||||||
end
|
procedure.draft_revision.remove_type_de_champ(removed_and_published_type_de_champ.stable_id)
|
||||||
|
procedure.draft_revision.add_type_de_champ(libelle: 'new type de champ', type_champ: 'text')
|
||||||
|
procedure.publish_revision!
|
||||||
|
procedure.reload
|
||||||
|
procedure.draft_revision.remove_type_de_champ(removed_type_de_champ.stable_id)
|
||||||
|
procedure.draft_revision.add_type_de_champ(libelle: 'draft type de champ', type_champ: 'text')
|
||||||
|
|
||||||
|
dossier
|
||||||
|
|
||||||
patch :update,
|
patch :update,
|
||||||
params: {
|
params: {
|
||||||
procedure_id: procedure.id,
|
procedure_id: procedure.id,
|
||||||
attestation_template: attestation_params
|
attestation_template: attestation_params
|
||||||
}
|
}
|
||||||
procedure.reload
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'and revisions are not activated' do
|
context 'normal' do
|
||||||
it do
|
it do
|
||||||
expect(procedure.draft_attestation_template).to eq(procedure.published_attestation_template)
|
expect(response).to redirect_to edit_admin_procedure_attestation_template_path(procedure)
|
||||||
expect(procedure.draft_attestation_template.title).to eq('t')
|
expect(procedure.attestation_template.title).to eq(title)
|
||||||
|
expect(procedure.attestation_template.body).to eq(body)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'and revisions are activated' do
|
context 'with invalid tag' do
|
||||||
let(:revisions_enabled) { true }
|
let(:body) { 'body --yolo--' }
|
||||||
it do
|
|
||||||
expect(procedure.draft_attestation_template).not_to eq(procedure.published_attestation_template)
|
it { expect(flash.alert).to eq(['Le contenu du modèle de l’attestation réfère au champ "yolo" qui n’existe pas']) }
|
||||||
expect(procedure.draft_attestation_template.title).to eq('t')
|
|
||||||
expect(procedure.published_attestation_template.title).to eq('a')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with removed champ' do
|
||||||
|
let(:body) { "body --#{removed_type_de_champ.libelle}--" }
|
||||||
|
|
||||||
|
it { expect(flash.alert).to eq(["Le contenu du modèle de l’attestation réfère au champ \"#{removed_type_de_champ.libelle}\" qui a été supprimé mais la suppression n’est pas encore publiée"]) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with removed and published' do
|
||||||
|
let(:body) { "body --#{removed_and_published_type_de_champ.libelle}--" }
|
||||||
|
|
||||||
|
it { expect(flash.alert).to eq(["Le contenu du modèle de l’attestation réfère au champ \"#{removed_and_published_type_de_champ.libelle}\" qui a été supprimé"]) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with new champ missing on dossier submitted on previous revision' do
|
||||||
|
let(:dossier) { create(:dossier, :en_construction, procedure: procedure, revision: procedure.revisions.first) }
|
||||||
|
let(:body) { "body --#{new_type_de_champ.libelle}--" }
|
||||||
|
|
||||||
|
it { expect(flash.alert).to eq(["Le contenu du modèle de l’attestation réfère au champ \"#{new_type_de_champ.libelle}\" qui n’existe pas sur un des dossiers en cours de traitement"]) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with champ on draft' do
|
||||||
|
let(:body) { "body --#{draft_type_de_champ.libelle}--" }
|
||||||
|
|
||||||
|
it { expect(flash.alert).to eq(["Le contenu du modèle de l’attestation réfère au champ \"#{draft_type_de_champ.libelle}\" qui n’est pas encore publié"]) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,6 +4,7 @@ FactoryBot.define do
|
||||||
body { 'body' }
|
body { 'body' }
|
||||||
footer { 'footer' }
|
footer { 'footer' }
|
||||||
activated { true }
|
activated { true }
|
||||||
|
association :procedure
|
||||||
end
|
end
|
||||||
|
|
||||||
trait :with_files do
|
trait :with_files do
|
||||||
|
|
|
@ -210,8 +210,8 @@ FactoryBot.define do
|
||||||
|
|
||||||
trait :with_attestation do
|
trait :with_attestation do
|
||||||
after(:build) do |dossier, _evaluator|
|
after(:build) do |dossier, _evaluator|
|
||||||
dossier.revision.attestation_template ||= build(:attestation_template)
|
dossier.procedure.attestation_template ||= build(:attestation_template)
|
||||||
dossier.association(:attestation_template).target = dossier.revision.attestation_template
|
dossier.association(:attestation_template).target = dossier.procedure.attestation_template
|
||||||
dossier.attestation = dossier.build_attestation
|
dossier.attestation = dossier.build_attestation
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,7 +23,6 @@ FactoryBot.define do
|
||||||
types_de_champ_public { [] }
|
types_de_champ_public { [] }
|
||||||
types_de_champ_private { [] }
|
types_de_champ_private { [] }
|
||||||
updated_at { nil }
|
updated_at { nil }
|
||||||
attestation_template { nil }
|
|
||||||
dossier_submitted_message { nil }
|
dossier_submitted_message { nil }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -32,7 +31,7 @@ FactoryBot.define do
|
||||||
raise "use types_de_champ_public instead of types_de_champ"
|
raise "use types_de_champ_public instead of types_de_champ"
|
||||||
end
|
end
|
||||||
|
|
||||||
initial_revision = build(:procedure_revision, procedure: procedure, attestation_template: evaluator.attestation_template, dossier_submitted_message: evaluator.dossier_submitted_message)
|
initial_revision = build(:procedure_revision, procedure: procedure, dossier_submitted_message: evaluator.dossier_submitted_message)
|
||||||
|
|
||||||
if evaluator.types_de_champ_public.present?
|
if evaluator.types_de_champ_public.present?
|
||||||
if !evaluator.types_de_champ_public.first.is_a?(Hash)
|
if !evaluator.types_de_champ_public.first.is_a?(Hash)
|
||||||
|
|
|
@ -9,7 +9,6 @@ FactoryBot.define do
|
||||||
from_revision = evaluator.from_original
|
from_revision = evaluator.from_original
|
||||||
|
|
||||||
revision.procedure = from_revision.procedure
|
revision.procedure = from_revision.procedure
|
||||||
revision.attestation_template_id = from_revision.attestation_template_id
|
|
||||||
revision.dossier_submitted_message_id = from_revision.dossier_submitted_message_id
|
revision.dossier_submitted_message_id = from_revision.dossier_submitted_message_id
|
||||||
|
|
||||||
coordinate_map = {}
|
coordinate_map = {}
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
describe '20220112184331_revise_attestation_templates' do
|
|
||||||
let(:rake_task) { Rake::Task['after_party:revise_attestation_templates'] }
|
|
||||||
let(:procedure) { create(:procedure) }
|
|
||||||
let(:attestation_template) { create(:attestation_template, procedure_id: procedure.id) }
|
|
||||||
|
|
||||||
subject(:run_task) do
|
|
||||||
attestation_template
|
|
||||||
rake_task.invoke
|
|
||||||
attestation_template.reload
|
|
||||||
end
|
|
||||||
|
|
||||||
after { rake_task.reenable }
|
|
||||||
|
|
||||||
describe 'revise_attestation_templates' do
|
|
||||||
it 'attaches the attestation_template to the latest revision (without removing the link between attestation_template and procedure for now)' do
|
|
||||||
expect(procedure.revisions.first.attestation_template_id).to be_nil
|
|
||||||
run_task
|
|
||||||
expect(attestation_template.procedure_id).to eq(procedure.id)
|
|
||||||
expect(procedure.revisions.first.attestation_template_id).to eq(attestation_template.id)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,51 +0,0 @@
|
||||||
describe '20220211090402_reassign_redundant_attestation_templates' do
|
|
||||||
let(:rake_task) { Rake::Task['after_party:reassign_redundant_attestation_templates'] }
|
|
||||||
let(:procedure) { create(:procedure, :published) }
|
|
||||||
let(:procedure_with_revisions) { create(:procedure, :published) }
|
|
||||||
|
|
||||||
before do
|
|
||||||
procedure.published_revision.update(attestation_template: create(:attestation_template))
|
|
||||||
procedure.draft_revision.update(attestation_template: procedure.published_attestation_template.dup)
|
|
||||||
|
|
||||||
Flipper.enable(:procedure_revisions, procedure_with_revisions)
|
|
||||||
procedure_with_revisions.published_revision.update(attestation_template: create(:attestation_template))
|
|
||||||
procedure_with_revisions.draft_revision.update(attestation_template: procedure_with_revisions.published_attestation_template.dup)
|
|
||||||
end
|
|
||||||
|
|
||||||
subject(:run_task) do
|
|
||||||
rake_task.invoke
|
|
||||||
procedure.reload
|
|
||||||
procedure_with_revisions.reload
|
|
||||||
end
|
|
||||||
|
|
||||||
after { rake_task.reenable }
|
|
||||||
|
|
||||||
describe 'reassign_redundant_attestation_templates' do
|
|
||||||
it 'reassign draft attestation template as published attestation template on procedures without revisions' do
|
|
||||||
expect(procedure.published_attestation_template).not_to be_nil
|
|
||||||
expect(procedure.draft_attestation_template).not_to be_nil
|
|
||||||
expect(procedure.draft_attestation_template).not_to eq(procedure.published_attestation_template)
|
|
||||||
|
|
||||||
expect(procedure_with_revisions.published_attestation_template).not_to be_nil
|
|
||||||
expect(procedure_with_revisions.draft_attestation_template).not_to be_nil
|
|
||||||
expect(procedure_with_revisions.draft_attestation_template).not_to eq(procedure_with_revisions.published_attestation_template)
|
|
||||||
|
|
||||||
orphans = AttestationTemplate.where(procedure_id: nil).left_outer_joins(:revisions).filter { |a| a.revisions.empty? }
|
|
||||||
expect(orphans).to eq([])
|
|
||||||
to_be_orphan = procedure.published_attestation_template
|
|
||||||
|
|
||||||
run_task
|
|
||||||
|
|
||||||
expect(procedure.published_attestation_template).not_to be_nil
|
|
||||||
expect(procedure.draft_attestation_template).not_to be_nil
|
|
||||||
expect(procedure.draft_attestation_template).to eq(procedure.published_attestation_template)
|
|
||||||
|
|
||||||
expect(procedure_with_revisions.published_attestation_template).not_to be_nil
|
|
||||||
expect(procedure_with_revisions.draft_attestation_template).not_to be_nil
|
|
||||||
expect(procedure_with_revisions.draft_attestation_template).not_to eq(procedure_with_revisions.published_attestation_template)
|
|
||||||
|
|
||||||
orphans = AttestationTemplate.where(procedure_id: nil).left_outer_joins(:revisions).filter { |a| a.revisions.empty? }
|
|
||||||
expect(orphans).to eq([to_be_orphan])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -775,20 +775,20 @@ describe Dossier do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when the dossier is in en_instruction state ' do
|
context 'when the dossier is in en_instruction state ' do
|
||||||
let!(:dossier) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction)) }
|
let!(:dossier) { create(:dossier, :en_instruction, procedure: procedure) }
|
||||||
|
|
||||||
context 'when the procedure has no attestation' do
|
context 'when the procedure has no attestation' do
|
||||||
it { expect(dossier.attestation).to be_nil }
|
it { expect(dossier.attestation).to be_nil }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when the procedure has an unactivated attestation' do
|
context 'when the procedure has an unactivated attestation' do
|
||||||
let(:attestation_template) { AttestationTemplate.new(activated: false) }
|
let(:attestation_template) { build(:attestation_template, activated: false) }
|
||||||
|
|
||||||
it { expect(dossier.attestation).to be_nil }
|
it { expect(dossier.attestation).to be_nil }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when the procedure attached has an activated attestation' do
|
context 'when the procedure attached has an activated attestation' do
|
||||||
let(:attestation_template) { AttestationTemplate.new(activated: true) }
|
let(:attestation_template) { build(:attestation_template, activated: true) }
|
||||||
|
|
||||||
it { expect(dossier.attestation).not_to be_nil }
|
it { expect(dossier.attestation).not_to be_nil }
|
||||||
end
|
end
|
||||||
|
|
|
@ -904,7 +904,7 @@ describe Procedure do
|
||||||
create(
|
create(
|
||||||
:procedure,
|
:procedure,
|
||||||
:published,
|
:published,
|
||||||
attestation_template: create(:attestation_template),
|
attestation_template: build(:attestation_template),
|
||||||
dossier_submitted_message: create(:dossier_submitted_message),
|
dossier_submitted_message: create(:dossier_submitted_message),
|
||||||
types_de_champ_public: [{ type: :text, libelle: 'published tdc' }]
|
types_de_champ_public: [{ type: :text, libelle: 'published tdc' }]
|
||||||
)
|
)
|
||||||
|
@ -913,7 +913,7 @@ describe Procedure do
|
||||||
it "should reset draft revision" do
|
it "should reset draft revision" do
|
||||||
procedure.draft_revision.add_type_de_champ(tdc_attributes)
|
procedure.draft_revision.add_type_de_champ(tdc_attributes)
|
||||||
previous_draft_revision = procedure.draft_revision
|
previous_draft_revision = procedure.draft_revision
|
||||||
previous_attestation_template = previous_draft_revision.attestation_template
|
previous_attestation_template = procedure.attestation_template
|
||||||
previous_dossier_submitted_message = previous_draft_revision.dossier_submitted_message
|
previous_dossier_submitted_message = previous_draft_revision.dossier_submitted_message
|
||||||
|
|
||||||
expect(procedure.draft_changed?).to be_truthy
|
expect(procedure.draft_changed?).to be_truthy
|
||||||
|
@ -921,7 +921,7 @@ describe Procedure do
|
||||||
expect(procedure.draft_changed?).to be_falsey
|
expect(procedure.draft_changed?).to be_falsey
|
||||||
expect(procedure.draft_revision).not_to eq(previous_draft_revision)
|
expect(procedure.draft_revision).not_to eq(previous_draft_revision)
|
||||||
expect { previous_draft_revision.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
expect { previous_draft_revision.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||||
expect(procedure.draft_revision.attestation_template).to eq(previous_attestation_template)
|
expect(procedure.attestation_template).to eq(previous_attestation_template)
|
||||||
expect(procedure.draft_revision.dossier_submitted_message).to eq(previous_dossier_submitted_message)
|
expect(procedure.draft_revision.dossier_submitted_message).to eq(previous_dossier_submitted_message)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ describe 'As an administrateur, I want to manage the procedure’s attestation',
|
||||||
fill_in "Corps du document", with: 'BOOM'
|
fill_in "Corps du document", with: 'BOOM'
|
||||||
find('.toggle-switch-control').click
|
find('.toggle-switch-control').click
|
||||||
click_on 'Enregistrer'
|
click_on 'Enregistrer'
|
||||||
page.find(".alert-success", text: "L'attestation a bien été sauvegardée")
|
page.find(".alert-success", text: "Le model de l’attestation a bien été enregistrée")
|
||||||
|
|
||||||
# check attestation
|
# check attestation
|
||||||
visit admin_procedure_path(procedure)
|
visit admin_procedure_path(procedure)
|
||||||
|
@ -49,7 +49,7 @@ describe 'As an administrateur, I want to manage the procedure’s attestation',
|
||||||
find_attestation_card.click
|
find_attestation_card.click
|
||||||
find('.toggle-switch-control').click
|
find('.toggle-switch-control').click
|
||||||
click_on 'Enregistrer'
|
click_on 'Enregistrer'
|
||||||
page.find(".alert-success", text: "L'attestation a bien été modifiée")
|
page.find(".alert-success", text: "Le model de l’attestation a bien été modifiée")
|
||||||
|
|
||||||
# check attestation is now disabled
|
# check attestation is now disabled
|
||||||
visit admin_procedure_path(procedure)
|
visit admin_procedure_path(procedure)
|
||||||
|
|
Loading…
Reference in a new issue