2021-11-25 16:26:55 +01:00
|
|
|
require 'system/administrateurs/procedure_spec_helper'
|
2016-12-26 10:56:48 +01:00
|
|
|
|
2021-10-26 11:44:53 +02:00
|
|
|
describe 'As an administrateur I wanna clone a procedure', js: true do
|
2018-05-23 23:32:49 +02:00
|
|
|
include ProcedureSpecHelper
|
|
|
|
|
2016-12-26 10:56:48 +01:00
|
|
|
let(:administrateur) { create(:administrateur) }
|
|
|
|
|
|
|
|
before do
|
2020-08-27 19:56:34 +02:00
|
|
|
create(:procedure, :with_service, :with_instructeur,
|
|
|
|
aasm_state: :publiee,
|
2019-08-14 18:05:01 +02:00
|
|
|
administrateurs: [administrateur],
|
|
|
|
libelle: 'libellé de la procédure',
|
2020-08-27 19:56:34 +02:00
|
|
|
path: 'libelle-de-la-procedure')
|
2019-08-09 10:46:39 +02:00
|
|
|
login_as administrateur.user, scope: :user
|
2016-12-26 10:56:48 +01:00
|
|
|
end
|
|
|
|
|
2019-08-14 18:05:01 +02:00
|
|
|
context 'Cloning a procedure owned by the current admin' do
|
|
|
|
scenario do
|
|
|
|
visit admin_procedures_path
|
2016-12-26 10:56:48 +01:00
|
|
|
expect(page.find_by_id('procedures')['data-item-count']).to eq('1')
|
2020-07-28 15:15:56 +02:00
|
|
|
page.all('.procedures-actions-btn').first.click
|
2016-12-26 10:56:48 +01:00
|
|
|
page.all('.clone-btn').first.click
|
2020-09-08 12:35:44 +02:00
|
|
|
visit admin_procedures_path(statut: "brouillons")
|
2019-08-14 18:05:01 +02:00
|
|
|
expect(page.find_by_id('procedures')['data-item-count']).to eq('1')
|
|
|
|
click_on Procedure.last.libelle
|
2022-08-17 09:06:04 +02:00
|
|
|
expect(page).to have_current_path(admin_procedure_path(id: Procedure.last))
|
2019-08-14 18:05:01 +02:00
|
|
|
|
2022-08-17 09:06:04 +02:00
|
|
|
# select service
|
2022-10-14 16:55:29 +02:00
|
|
|
find("#service .fr-btn").click
|
2022-08-17 17:55:10 +02:00
|
|
|
click_on "Assigner"
|
2022-08-17 09:06:04 +02:00
|
|
|
|
|
|
|
# then publish
|
2020-07-15 10:48:11 +02:00
|
|
|
find('#publish-procedure-link').click
|
2020-09-08 12:35:44 +02:00
|
|
|
expect(find_field('procedure_path').value).to eq 'libelle-de-la-procedure'
|
|
|
|
fill_in 'lien_site_web', with: 'http://some.website'
|
|
|
|
click_on 'publish'
|
2019-08-14 18:05:01 +02:00
|
|
|
|
|
|
|
page.refresh
|
|
|
|
|
2020-09-08 12:35:44 +02:00
|
|
|
visit admin_procedures_path(statut: "archivees")
|
2019-08-14 18:05:01 +02:00
|
|
|
expect(page.find_by_id('procedures')['data-item-count']).to eq('1')
|
2020-09-08 12:35:44 +02:00
|
|
|
visit admin_procedures_path(statut: "brouillons")
|
2019-08-14 18:05:01 +02:00
|
|
|
expect(page.find_by_id('procedures')['data-item-count']).to eq('0')
|
2016-12-26 10:56:48 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|