demarches-normaliennes/spec/features/admin/procedure_publish_spec.rb
2020-09-17 14:03:31 +02:00

96 lines
2.9 KiB
Ruby
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
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
context 'lorsquune démarche est en test' do
scenario 'un administrateur peut la publier' do
visit admin_procedures_path(statut: "brouillons")
click_on procedure.libelle
find('#publish-procedure-link').click
expect(find_field('procedure_path').value).to eq procedure.path
fill_in 'lien_site_web', with: 'http://some.website'
click_on 'Publier'
expect(page).to have_text('Démarche publiée')
expect(page).to have_selector('#preview-procedure')
end
end
context 'lorsquune 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
visit admin_procedures_path(statut: "archivees")
click_on procedure.libelle
find('#publish-procedure-link').click
expect(find_field('procedure_path').value).to eq procedure.path
fill_in 'lien_site_web', with: 'http://some.website'
click_on 'publish'
expect(page).to have_text('Démarche publiée')
expect(page).to have_selector('#preview-procedure')
end
end
context 'lorsquune 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
visit admin_procedures_path(statut: "archivees")
click_on procedure.libelle
find('#publish-procedure-link').click
expect(find_field('procedure_path').value).to eq procedure.path
fill_in 'lien_site_web', with: 'http://some.website'
click_on 'Publier'
expect(page).to have_text('Démarche publiée')
expect(page).to have_selector('#preview-procedure')
end
end
end