feat(attestation): can reset draft attestation
This commit is contained in:
parent
a540f8dccb
commit
cd07ee173f
5 changed files with 38 additions and 4 deletions
|
@ -104,6 +104,13 @@ module Administrateurs
|
||||||
|
|
||||||
def create = update
|
def create = update
|
||||||
|
|
||||||
|
def reset
|
||||||
|
@procedure.attestation_templates_v2.draft&.destroy_all
|
||||||
|
|
||||||
|
flash.notice = "Les modifications ont été réinitialisées."
|
||||||
|
redirect_to edit_admin_procedure_attestation_template_v2_path(@procedure)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def ensure_feature_active
|
def ensure_feature_active
|
||||||
|
|
|
@ -3,8 +3,13 @@
|
||||||
%p.flex.justify-between.align-center.fr-text-default--warning
|
%p.flex.justify-between.align-center.fr-text-default--warning
|
||||||
%span
|
%span
|
||||||
= dsfr_icon("fr-icon-warning-fill fr-mr-1v")
|
= dsfr_icon("fr-icon-warning-fill fr-mr-1v")
|
||||||
Les modifications effectuées ne seront appliquées qu’une fois que vous aurez publié cette version de l’attestation.
|
Les modifications effectuées ne seront appliquées qu’à la prochaine publication.
|
||||||
%span
|
%span
|
||||||
|
|
||||||
|
|
||||||
|
= link_to reset_admin_procedure_attestation_template_v2_path(@procedure), class: "fr-btn fr-btn--secondary fr-ml-2w", method: :post do
|
||||||
|
Réinitialiser les modifications
|
||||||
|
|
||||||
%button.fr-btn.fr-ml-2w{ form: "attestation-template", name: field_name(:attestation_template, :state), value: "published",
|
%button.fr-btn.fr-ml-2w{ form: "attestation-template", name: field_name(:attestation_template, :state), value: "published",
|
||||||
data: { 'disable-with': "Publication en cours…", controller: 'autosave-submit' } }
|
data: { 'disable-with': "Publication en cours…", controller: 'autosave-submit' } }
|
||||||
Publier l’attestation
|
Publier les modifications
|
||||||
|
|
|
@ -684,7 +684,9 @@ Rails.application.routes.draw do
|
||||||
get 'add_champ_engagement_juridique'
|
get 'add_champ_engagement_juridique'
|
||||||
end
|
end
|
||||||
|
|
||||||
resource :attestation_template_v2, only: [:show, :edit, :update, :create]
|
resource :attestation_template_v2, only: [:show, :edit, :update, :create] do
|
||||||
|
post :reset
|
||||||
|
end
|
||||||
|
|
||||||
resource :dossier_submitted_message, only: [:edit, :update, :create]
|
resource :dossier_submitted_message, only: [:edit, :update, :create]
|
||||||
# ADDED TO ACCESS IT FROM THE IFRAME
|
# ADDED TO ACCESS IT FROM THE IFRAME
|
||||||
|
|
|
@ -233,4 +233,25 @@ describe Administrateurs::AttestationTemplateV2sController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'POST reset' do
|
||||||
|
render_views
|
||||||
|
|
||||||
|
before {
|
||||||
|
create(:attestation_template, :v2, :draft, procedure:)
|
||||||
|
}
|
||||||
|
|
||||||
|
subject do
|
||||||
|
patch :reset, params: { procedure_id: procedure.id }
|
||||||
|
response.body
|
||||||
|
end
|
||||||
|
|
||||||
|
it "delete draft, keep published" do
|
||||||
|
expect(procedure.attestation_templates.count).to eq(2)
|
||||||
|
expect(subject).to redirect_to(edit_admin_procedure_attestation_template_v2_path(procedure))
|
||||||
|
expect(flash.notice).to include("réinitialisées")
|
||||||
|
expect(procedure.attestation_templates.count).to eq(1)
|
||||||
|
expect(procedure.attestation_templates.first).to eq(attestation_template)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -138,7 +138,6 @@ describe 'As an administrateur, I want to manage the procedure’s attestation',
|
||||||
expect(page).to have_field("Contenu du pied de page", with: "line1\nline2\nline3\nline4")
|
expect(page).to have_field("Contenu du pied de page", with: "line1\nline2\nline3\nline4")
|
||||||
|
|
||||||
click_on "Publier"
|
click_on "Publier"
|
||||||
expect(page).to have_text("L’attestation a été publiée")
|
|
||||||
expect(attestation.reload).to be_published
|
expect(attestation.reload).to be_published
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue