diff --git a/app/views/administrateurs/procedures/_detail.html.haml b/app/views/administrateurs/procedures/_detail.html.haml index 09ceef9c9..f25a90fd1 100644 --- a/app/views/administrateurs/procedures/_detail.html.haml +++ b/app/views/administrateurs/procedures/_detail.html.haml @@ -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}" } diff --git a/app/views/administrateurs/procedures/all.html.haml b/app/views/administrateurs/procedures/all.html.haml index fda6e255a..1ac68b3be 100644 --- a/app/views/administrateurs/procedures/all.html.haml +++ b/app/views/administrateurs/procedures/all.html.haml @@ -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' } N° + %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 } diff --git a/config/locales/fr.yml b/config/locales/fr.yml index e2cd5e7dc..f17e106ca 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -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 l’administrateur (ajout d’un champ, publication de la démarche...) entraînera sa suppression." diff --git a/spec/system/administrateurs/procedure_cloning_spec.rb b/spec/system/administrateurs/procedure_cloning_spec.rb index c8e301253..dc6dfafe4 100644 --- a/spec/system/administrateurs/procedure_cloning_spec.rb +++ b/spec/system/administrateurs/procedure_cloning_spec.rb @@ -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