Merge pull request #8551 from demarches-simplifiees/feat/8368

ETQ admin, je peux cloner une démarche à partir de la vue "toutes les démarches"
This commit is contained in:
Kara Diaby 2023-02-09 10:19:39 +01:00 committed by GitHub
commit 18cdcecd92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 3 deletions

View file

@ -11,6 +11,8 @@
%td= procedure.administrateurs.count
%td= t procedure.aasm_state, scope: 'activerecord.attributes.procedure.aasm_state'
%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
%tr.procedure{ id: "procedure_detail_#{procedure.id}" }

View file

@ -15,7 +15,7 @@
.fr-table.fr-table--bordered
%table#all-demarches
%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' }
- if @filter.libelle
.selected-query.fr-mb-2w
@ -40,10 +40,11 @@
%tr
%th{ scope: 'col' }
%th{ scope: 'col' } Démarche
%th{ scope: 'col' }
%th{ scope: 'col' }
%th{ scope: 'col' } Administrateurs
%th{ scope: 'col' } Statut
%th{ scope: 'col' } Date
%th{ scope: 'col' } Action
%tbody{ 'data-turbo': 'true' }
- @procedures.each do |procedure|
= render partial: 'detail', locals: { procedure: procedure, show_detail: false }

View file

@ -541,6 +541,9 @@ fr:
deleted:
one: Supprimée
other: Supprimées
procedures:
one: Démarche
other: Démarches
users:
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."

View file

@ -10,7 +10,8 @@ describe 'As an administrateur I wanna clone a procedure', js: true do
aasm_state: :publiee,
administrateurs: [administrateur],
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
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')
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