2021-11-25 16:26:55 +01:00
|
|
|
|
require 'system/administrateurs/procedure_spec_helper'
|
2018-09-19 17:12:12 +02:00
|
|
|
|
|
2021-10-26 11:44:53 +02:00
|
|
|
|
describe 'Administrateurs can edit procedures', js: true do
|
2018-09-19 17:12:12 +02:00
|
|
|
|
include ProcedureSpecHelper
|
|
|
|
|
|
|
|
|
|
let(:administrateur) { create(:administrateur) }
|
|
|
|
|
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')
|
2019-10-21 18:12:57 +02:00
|
|
|
|
within('.procedure-form__preview') do
|
|
|
|
|
expect(page).to have_content('Ma petite démarche')
|
|
|
|
|
end
|
2018-09-19 17:12:12 +02:00
|
|
|
|
|
|
|
|
|
click_on 'Enregistrer'
|
|
|
|
|
|
2022-02-22 16:09:00 +01:00
|
|
|
|
expect(page).to have_selector('.breadcrumbs 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-02-22 16:09:00 +01:00
|
|
|
|
expect(page).to have_selector('.breadcrumbs li', text: 'Ma petite démarche')
|
2018-09-19 17:12:12 +02:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|