2021-11-25 16:26:55 +01:00
|
|
|
|
require 'system/administrateurs/procedure_spec_helper'
|
2018-09-19 17:12:12 +02:00
|
|
|
|
|
2023-11-06 15:15:51 +01:00
|
|
|
|
describe 'Administrateurs can edit procedures', js: true do
|
2018-09-19 17:12:12 +02:00
|
|
|
|
include ProcedureSpecHelper
|
|
|
|
|
|
2024-06-01 22:50:48 +02:00
|
|
|
|
let(:administrateur) { administrateurs(:default_admin) }
|
2018-09-19 17:12:12 +02:00
|
|
|
|
let!(:procedure) do
|
|
|
|
|
create(:procedure_with_dossiers,
|
|
|
|
|
:published,
|
|
|
|
|
:with_path,
|
|
|
|
|
:with_type_de_champ,
|
|
|
|
|
administrateur: administrateur)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
before do
|
2019-08-09 10:46:39 +02:00
|
|
|
|
login_as administrateur.user, scope: :user
|
2018-09-19 17:12:12 +02:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'when the procedure is in draft' do
|
|
|
|
|
let!(:procedure) do
|
|
|
|
|
create(:procedure_with_dossiers,
|
|
|
|
|
:with_path,
|
|
|
|
|
:with_type_de_champ,
|
|
|
|
|
administrateur: administrateur)
|
|
|
|
|
end
|
|
|
|
|
|
2019-01-16 17:23:33 +01:00
|
|
|
|
scenario 'the administrator can edit the libelle' do
|
2020-09-08 12:35:44 +02:00
|
|
|
|
visit admin_procedures_path(statut: "brouillons")
|
2018-09-19 17:12:12 +02:00
|
|
|
|
click_on procedure.libelle
|
2020-07-15 10:48:11 +02:00
|
|
|
|
find('#presentation').click
|
2018-09-19 17:12:12 +02:00
|
|
|
|
|
|
|
|
|
expect(page).to have_field('procedure_libelle', with: procedure.libelle)
|
|
|
|
|
|
|
|
|
|
fill_in('procedure_libelle', with: 'Ma petite démarche')
|
|
|
|
|
click_on 'Enregistrer'
|
|
|
|
|
|
2022-08-17 13:53:07 +02:00
|
|
|
|
expect(page).to have_selector('.fr-breadcrumb li', text: 'Ma petite démarche')
|
2018-09-19 17:12:12 +02:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'when the procedure is published' do
|
|
|
|
|
scenario 'the administrator can edit the libellé, but can‘t change the path' do
|
|
|
|
|
visit root_path
|
|
|
|
|
click_on procedure.libelle
|
2020-07-15 10:48:11 +02:00
|
|
|
|
find('#presentation').click
|
2018-09-19 17:12:12 +02:00
|
|
|
|
|
|
|
|
|
expect(page).to have_field('procedure_libelle', with: procedure.libelle)
|
|
|
|
|
expect(page).not_to have_field('procedure_path')
|
|
|
|
|
|
|
|
|
|
fill_in('procedure_libelle', with: 'Ma petite démarche')
|
|
|
|
|
|
|
|
|
|
click_on 'Enregistrer'
|
|
|
|
|
|
2022-08-17 13:53:07 +02:00
|
|
|
|
expect(page).to have_selector('.fr-breadcrumb li', text: 'Ma petite démarche')
|
2018-09-19 17:12:12 +02:00
|
|
|
|
end
|
|
|
|
|
end
|
2023-03-08 11:27:31 +01:00
|
|
|
|
|
|
|
|
|
context 'when we associate tags' do
|
|
|
|
|
scenario 'the administrator can edit and persist the tags' do
|
|
|
|
|
procedure.update!(tags: ['social'])
|
|
|
|
|
|
|
|
|
|
visit edit_admin_procedure_path(procedure)
|
|
|
|
|
select_combobox('procedure_tags_combo', 'planete', 'planete', check: false)
|
|
|
|
|
click_on 'Enregistrer'
|
|
|
|
|
|
|
|
|
|
expect(procedure.reload.tags).to eq(['social', 'planete'])
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
scenario 'the tags are persisted when non interacting with the tags combobox' do
|
|
|
|
|
procedure.update!(tags: ['social'])
|
|
|
|
|
|
|
|
|
|
visit edit_admin_procedure_path(procedure)
|
|
|
|
|
click_on 'Enregistrer'
|
|
|
|
|
|
|
|
|
|
expect(procedure.reload.tags).to eq(['social'])
|
|
|
|
|
end
|
|
|
|
|
end
|
2023-03-10 10:16:36 +01:00
|
|
|
|
|
|
|
|
|
context 'when duree extension > 12' do
|
|
|
|
|
let!(:procedure) do
|
|
|
|
|
create(:procedure_with_dossiers,
|
|
|
|
|
:published,
|
|
|
|
|
:with_path,
|
|
|
|
|
:with_type_de_champ,
|
|
|
|
|
duree_conservation_dossiers_dans_ds: 24,
|
|
|
|
|
max_duree_conservation_dossiers_dans_ds: 24,
|
|
|
|
|
administrateur: administrateur)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
scenario 'the administrator can edit and persist title' do
|
|
|
|
|
visit edit_admin_procedure_path(procedure)
|
|
|
|
|
fill_in('Titre de la démarche', with: 'Hello')
|
|
|
|
|
expect { click_on 'Enregistrer' }.to change { procedure.reload.libelle }
|
|
|
|
|
end
|
|
|
|
|
end
|
2018-09-19 17:12:12 +02:00
|
|
|
|
end
|