Permet de cloner une démarche depuis la page toutes les démarches

This commit is contained in:
Kara Diaby 2023-02-02 06:59:46 +01:00
parent 9733121fca
commit f212fa1008
4 changed files with 45 additions and 3 deletions

View file

@ -11,6 +11,8 @@
%td= procedure.administrateurs.count %td= procedure.administrateurs.count
%td= t procedure.aasm_state, scope: 'activerecord.attributes.procedure.aasm_state' %td= t procedure.aasm_state, scope: 'activerecord.attributes.procedure.aasm_state'
%td= l(procedure.published_at, format: :message_date_without_time) %td= l(procedure.published_at, format: :message_date_without_time)
%td= link_to('Cloner', admin_procedure_clone_path(procedure.id, from_new_from_existing: true), 'data-method' => :put, class: 'fr-btn fr-btn--tertiary fr-btn--sm')
- if show_detail - if show_detail
%tr.procedure{ id: "procedure_detail_#{procedure.id}" } %tr.procedure{ id: "procedure_detail_#{procedure.id}" }

View file

@ -15,7 +15,7 @@
.fr-table.fr-table--bordered .fr-table.fr-table--bordered
%table#all-demarches %table#all-demarches
%caption %caption
= "#{@procedures.total_count} démarches" = "#{@procedures.total_count} #{t('pluralize.procedures', count: @procedures.total_count)}"
%span.hidden.spinner{ 'aria-hidden': 'true', 'data-turbo-target': 'spinner' } %span.hidden.spinner{ 'aria-hidden': 'true', 'data-turbo-target': 'spinner' }
- if @filter.libelle - if @filter.libelle
.selected-query.fr-mb-2w .selected-query.fr-mb-2w
@ -40,10 +40,11 @@
%tr %tr
%th{ scope: 'col' } %th{ scope: 'col' }
%th{ scope: 'col' } Démarche %th{ scope: 'col' } Démarche
%th{ scope: 'col' } %th{ scope: 'col' }
%th{ scope: 'col' } Administrateurs %th{ scope: 'col' } Administrateurs
%th{ scope: 'col' } Statut %th{ scope: 'col' } Statut
%th{ scope: 'col' } Date %th{ scope: 'col' } Date
%th{ scope: 'col' } Action
%tbody{ 'data-turbo': 'true' } %tbody{ 'data-turbo': 'true' }
- @procedures.each do |procedure| - @procedures.each do |procedure|
= render partial: 'detail', locals: { procedure: procedure, show_detail: false } = render partial: 'detail', locals: { procedure: procedure, show_detail: false }

View file

@ -541,6 +541,9 @@ fr:
deleted: deleted:
one: Supprimée one: Supprimée
other: Supprimées other: Supprimées
procedures:
one: Démarche
other: Démarches
users: users:
dossiers: dossiers:
test_procedure: "Ce dossier est déposé sur une démarche en test. Toute modification de la démarche par ladministrateur (ajout dun champ, publication de la démarche...) entraînera sa suppression." test_procedure: "Ce dossier est déposé sur une démarche en test. Toute modification de la démarche par ladministrateur (ajout dun champ, publication de la démarche...) entraînera sa suppression."

View file

@ -10,7 +10,8 @@ describe 'As an administrateur I wanna clone a procedure', js: true do
aasm_state: :publiee, aasm_state: :publiee,
administrateurs: [administrateur], administrateurs: [administrateur],
libelle: 'libellé de la procédure', libelle: 'libellé de la procédure',
path: 'libelle-de-la-procedure') path: 'libelle-de-la-procedure',
published_at: Time.zone.now)
login_as administrateur.user, scope: :user login_as administrateur.user, scope: :user
end end
@ -48,4 +49,39 @@ describe 'As an administrateur I wanna clone a procedure', js: true do
expect(page.find_by_id('procedures')['data-item-count']).to eq('0') expect(page.find_by_id('procedures')['data-item-count']).to eq('0')
end end
end end
context 'Cloning a procedure from the all procedure page' do
scenario do
visit all_admin_procedures_path
expect(page).to have_content(Procedure.last.libelle)
find('.button_to>button').click
click_on 'Cloner'
visit admin_procedures_path(statut: "brouillons")
expect(page.find_by_id('procedures')['data-item-count']).to eq('1')
click_on Procedure.last.libelle
expect(page).to have_current_path(admin_procedure_path(id: Procedure.last))
# select service
find("#service .fr-btn").click
click_on "Assigner"
# select zone
find("#zones .fr-btn").click
check Zone.last.current_label
click_on 'Enregistrer'
# then publish
find('#publish-procedure-link').click
expect(find_field('procedure_path').value).to eq 'libelle-de-la-procedure'
fill_in 'lien_site_web', with: 'http://some.website'
click_on 'publish'
page.refresh
visit admin_procedures_path(statut: "archivees")
expect(page.find_by_id('procedures')['data-item-count']).to eq('1')
visit admin_procedures_path(statut: "brouillons")
expect(page.find_by_id('procedures')['data-item-count']).to eq('0')
end
end
end end