2018-09-19 17:12:12 +02:00
|
|
|
|
require 'features/admin/procedure_spec_helper'
|
|
|
|
|
|
|
|
|
|
feature 'Administrateurs can edit procedures', js: true do
|
|
|
|
|
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
|
2018-09-19 17:12:12 +02:00
|
|
|
|
visit admin_procedures_draft_path
|
|
|
|
|
click_on procedure.libelle
|
2020-07-13 11:36:42 +02:00
|
|
|
|
click_on 'Description'
|
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'
|
|
|
|
|
|
|
|
|
|
expect(page).to have_field('procedure_libelle', with: 'Ma petite démarche')
|
|
|
|
|
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-13 11:36:42 +02:00
|
|
|
|
click_on 'Description'
|
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'
|
|
|
|
|
|
|
|
|
|
expect(page).to have_field('procedure_libelle', with: 'Ma petite démarche')
|
|
|
|
|
end
|
|
|
|
|
end
|
2020-02-03 15:11:37 +01:00
|
|
|
|
|
|
|
|
|
scenario 'the administrator can add another administrator' do
|
|
|
|
|
another_administrateur = create(:administrateur)
|
|
|
|
|
visit admin_procedure_path(procedure)
|
2020-07-13 11:36:42 +02:00
|
|
|
|
click_on 'Administrateurs'
|
2020-02-03 15:11:37 +01:00
|
|
|
|
|
|
|
|
|
fill_in('administrateur_email', with: another_administrateur.email)
|
|
|
|
|
|
|
|
|
|
click_on 'Ajouter comme administrateur'
|
|
|
|
|
|
|
|
|
|
within('.alert-success') do
|
|
|
|
|
expect(page).to have_content(another_administrateur.email)
|
|
|
|
|
end
|
|
|
|
|
end
|
2018-09-19 17:12:12 +02:00
|
|
|
|
end
|