2020-03-13 15:32:30 +01:00
|
|
|
|
require 'features/admin/procedure_spec_helper'
|
|
|
|
|
|
|
|
|
|
feature 'Publication de démarches', js: true do
|
|
|
|
|
include ProcedureSpecHelper
|
|
|
|
|
|
|
|
|
|
let(:administrateur) { create(:administrateur) }
|
|
|
|
|
let(:instructeurs) { [administrateur.user.instructeur] }
|
|
|
|
|
let!(:procedure) do
|
|
|
|
|
create(:procedure_with_dossiers,
|
|
|
|
|
:with_path,
|
|
|
|
|
:with_type_de_champ,
|
|
|
|
|
:with_service,
|
|
|
|
|
instructeurs: instructeurs,
|
|
|
|
|
administrateur: administrateur)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
before do
|
|
|
|
|
login_as administrateur.user, scope: :user
|
|
|
|
|
end
|
|
|
|
|
|
2020-09-17 13:53:48 +02:00
|
|
|
|
context "lorsqu'on essaie d'accéder au backoffice déprécié" do
|
|
|
|
|
scenario "on est redirigé pour les démarches brouillon" do
|
|
|
|
|
visit admin_procedures_draft_path
|
|
|
|
|
expect(page).to have_current_path(admin_procedures_path(statut: "brouillons"))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
scenario "on est redirigé pour les démarches archivées" do
|
|
|
|
|
visit admin_procedures_archived_path
|
|
|
|
|
expect(page).to have_current_path(admin_procedures_path(statut: "archivees"))
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2020-03-13 15:32:30 +01:00
|
|
|
|
context 'lorsqu’une démarche est en test' do
|
|
|
|
|
scenario 'un administrateur peut la publier' do
|
2020-09-08 12:35:44 +02:00
|
|
|
|
visit admin_procedures_path(statut: "brouillons")
|
2020-03-13 15:32:30 +01:00
|
|
|
|
click_on procedure.libelle
|
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 procedure.path
|
|
|
|
|
fill_in 'lien_site_web', with: 'http://some.website'
|
|
|
|
|
click_on 'Publier'
|
2020-03-13 15:32:30 +01:00
|
|
|
|
|
|
|
|
|
expect(page).to have_text('Démarche publiée')
|
2020-09-08 12:35:44 +02:00
|
|
|
|
expect(page).to have_selector('#preview-procedure')
|
2020-03-13 15:32:30 +01:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'lorsqu’une démarche est close' do
|
|
|
|
|
let!(:procedure) do
|
|
|
|
|
create(:procedure_with_dossiers,
|
|
|
|
|
:closed,
|
|
|
|
|
:with_path,
|
|
|
|
|
:with_type_de_champ,
|
|
|
|
|
:with_service,
|
|
|
|
|
instructeurs: instructeurs,
|
|
|
|
|
administrateur: administrateur)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
scenario 'un administrateur peut la publier' do
|
2020-09-08 12:35:44 +02:00
|
|
|
|
visit admin_procedures_path(statut: "archivees")
|
2020-03-13 15:32:30 +01:00
|
|
|
|
click_on procedure.libelle
|
2020-07-15 10:48:11 +02:00
|
|
|
|
find('#publish-procedure-link').click
|
2020-03-13 15:32:30 +01:00
|
|
|
|
|
2020-09-08 12:35:44 +02:00
|
|
|
|
expect(find_field('procedure_path').value).to eq procedure.path
|
|
|
|
|
fill_in 'lien_site_web', with: 'http://some.website'
|
|
|
|
|
click_on 'publish'
|
2020-03-13 15:32:30 +01:00
|
|
|
|
|
|
|
|
|
expect(page).to have_text('Démarche publiée')
|
2020-09-08 12:35:44 +02:00
|
|
|
|
expect(page).to have_selector('#preview-procedure')
|
2020-03-13 15:32:30 +01:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'lorsqu’une démarche est dépublié' do
|
|
|
|
|
let!(:procedure) do
|
|
|
|
|
create(:procedure_with_dossiers,
|
|
|
|
|
:unpublished,
|
|
|
|
|
:with_path,
|
|
|
|
|
:with_type_de_champ,
|
|
|
|
|
:with_service,
|
|
|
|
|
instructeurs: instructeurs,
|
|
|
|
|
administrateur: administrateur)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
scenario 'un administrateur peut la publier' do
|
2020-09-08 12:35:44 +02:00
|
|
|
|
visit admin_procedures_path(statut: "archivees")
|
2020-03-13 15:32:30 +01:00
|
|
|
|
click_on procedure.libelle
|
2020-07-15 10:48:11 +02:00
|
|
|
|
find('#publish-procedure-link').click
|
2020-03-13 15:32:30 +01:00
|
|
|
|
|
2020-09-08 12:35:44 +02:00
|
|
|
|
expect(find_field('procedure_path').value).to eq procedure.path
|
|
|
|
|
fill_in 'lien_site_web', with: 'http://some.website'
|
|
|
|
|
click_on 'Publier'
|
2020-03-13 15:32:30 +01:00
|
|
|
|
|
|
|
|
|
expect(page).to have_text('Démarche publiée')
|
2020-09-08 12:35:44 +02:00
|
|
|
|
expect(page).to have_selector('#preview-procedure')
|
2020-03-13 15:32:30 +01:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|