Enable republish on démarches dépubliée
This commit is contained in:
parent
60998f410d
commit
b516cbc179
4 changed files with 118 additions and 17 deletions
|
@ -195,7 +195,11 @@ class Procedure < ApplicationRecord
|
||||||
def path_available?(administrateur, path)
|
def path_available?(administrateur, path)
|
||||||
procedure = other_procedure_with_path(path)
|
procedure = other_procedure_with_path(path)
|
||||||
|
|
||||||
procedure.blank? || administrateur.owns?(procedure)
|
procedure.blank? || (administrateur.owns?(procedure) && canonical_procedure_child?(procedure))
|
||||||
|
end
|
||||||
|
|
||||||
|
def canonical_procedure_child?(procedure)
|
||||||
|
!canonical_procedure || canonical_procedure == procedure || canonical_procedure == procedure.canonical_procedure
|
||||||
end
|
end
|
||||||
|
|
||||||
def locked?
|
def locked?
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
= render partial: 'admin/closed_mail_template_attestation_inconsistency_alert'
|
= render partial: 'admin/closed_mail_template_attestation_inconsistency_alert'
|
||||||
.row.white-back
|
.row.white-back
|
||||||
#procedure_show
|
|
||||||
= render 'modal_publish', procedure: @procedure, administrateur: @current_administrateur
|
= render 'modal_publish', procedure: @procedure, administrateur: @current_administrateur
|
||||||
= render partial: '/admin/procedures/modal_transfer'
|
= render 'modal_transfer'
|
||||||
|
|
||||||
|
#procedure_show
|
||||||
- if @procedure.brouillon?
|
- if @procedure.brouillon?
|
||||||
- if @procedure.missing_steps.present?
|
- if @procedure.missing_steps.present?
|
||||||
- missing_elements = []
|
- missing_elements = []
|
||||||
|
@ -12,20 +12,20 @@
|
||||||
- if @procedure.service.nil?
|
- if @procedure.service.nil?
|
||||||
- missing_elements << 'un service'
|
- missing_elements << 'un service'
|
||||||
- message = "Affectez #{missing_elements.join(' et ')} à votre démarche."
|
- message = "Affectez #{missing_elements.join(' et ')} à votre démarche."
|
||||||
%a.action_button.btn.btn-success#disabled-publish-procedure{ data: { toggle: :tooltip, placement: :bottom }, style: 'float: right; margin-top: 10px;', disabled: true, title: message }
|
%button.action_button.btn.btn-success#disabled-publish-procedure{ data: { toggle: :tooltip, placement: :bottom }, style: 'float: right; margin-top: 10px;', disabled: true, title: message }
|
||||||
%i.fa.fa-eraser
|
%i.fa.fa-eraser
|
||||||
Publier
|
Publier
|
||||||
- else
|
- else
|
||||||
%a.btn.btn-success#publish-procedure{ data: { target: '#publish-modal', toggle: :modal }, type: 'button', style: 'float: right; margin-top: 10px;' }
|
%button.btn.btn-success#publish-procedure{ data: { target: '#publish-modal', toggle: :modal }, type: 'button', style: 'float: right; margin-top: 10px;' }
|
||||||
%i.fa.fa-eraser
|
%i.fa.fa-eraser
|
||||||
Publier
|
Publier
|
||||||
|
|
||||||
%a.btn.btn-default#transfer-procedure{ data: { target: '#transfer-modal', toggle: :modal }, type: 'button', style: 'float: right; margin-top: 10px; margin-right: 10px;' }
|
%button.btn.btn-default#transfer-procedure{ data: { target: '#transfer-modal', toggle: :modal }, type: 'button', style: 'float: right; margin-top: 10px; margin-right: 10px;' }
|
||||||
%i.fa.fa-exchange
|
%i.fa.fa-exchange
|
||||||
Envoyer une copie
|
Envoyer une copie
|
||||||
|
|
||||||
- if @procedure.close?
|
- if @procedure.close? || @procedure.depubliee?
|
||||||
%a.btn.btn-default#reopen-procedure{ data: { target: '#publish-modal', toggle: :modal }, type: 'button', style: 'float: right; margin-top: 10px; margin-right: 10px;' }
|
%button.btn.btn-default#reopen-procedure{ data: { target: '#publish-modal', toggle: :modal }, type: 'button', style: 'float: right; margin-top: 10px; margin-right: 10px;' }
|
||||||
%i.fa.fa-rocket
|
%i.fa.fa-rocket
|
||||||
Réactiver
|
Réactiver
|
||||||
|
|
||||||
|
|
97
spec/features/admin/procedure_publish_spec.rb
Normal file
97
spec/features/admin/procedure_publish_spec.rb
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
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’une démarche est en test' do
|
||||||
|
scenario 'un administrateur peut la publier' do
|
||||||
|
visit admin_procedures_draft_path
|
||||||
|
click_on procedure.libelle
|
||||||
|
within "#procedure_show" do
|
||||||
|
click_on "Publier"
|
||||||
|
end
|
||||||
|
|
||||||
|
within '#publish-modal' do
|
||||||
|
expect(find_field('procedure_path').value).to eq procedure.path
|
||||||
|
fill_in 'lien_site_web', with: 'http://some.website'
|
||||||
|
click_on 'publish'
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(page).to have_text('Démarche publiée')
|
||||||
|
expect(page).to have_selector('.procedure-lien')
|
||||||
|
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
|
||||||
|
visit admin_procedures_archived_path
|
||||||
|
click_on procedure.libelle
|
||||||
|
within "#procedure_show" do
|
||||||
|
click_on "Réactiver"
|
||||||
|
end
|
||||||
|
|
||||||
|
within '#publish-modal' do
|
||||||
|
expect(find_field('procedure_path').value).to eq procedure.path
|
||||||
|
fill_in 'lien_site_web', with: 'http://some.website'
|
||||||
|
click_on 'publish'
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(page).to have_text('Démarche publiée')
|
||||||
|
expect(page).to have_selector('.procedure-lien')
|
||||||
|
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
|
||||||
|
visit admin_procedures_archived_path
|
||||||
|
click_on procedure.libelle
|
||||||
|
within "#procedure_show" do
|
||||||
|
click_on "Réactiver"
|
||||||
|
end
|
||||||
|
|
||||||
|
within '#publish-modal' do
|
||||||
|
expect(find_field('procedure_path').value).to eq procedure.path
|
||||||
|
fill_in 'lien_site_web', with: 'http://some.website'
|
||||||
|
click_on 'publish'
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(page).to have_text('Démarche publiée')
|
||||||
|
expect(page).to have_selector('.procedure-lien')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -14,9 +14,9 @@ describe 'admin/procedures/show.html.haml', type: :view do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'publish button is not visible' do
|
describe 'publish button is not visible' do
|
||||||
it { expect(rendered).not_to have_css('a#publish-procedure') }
|
it { expect(rendered).not_to have_css('button#publish-procedure') }
|
||||||
it { expect(rendered).not_to have_css('button#archive-procedure') }
|
it { expect(rendered).not_to have_css('button#archive-procedure') }
|
||||||
it { expect(rendered).not_to have_css('a#reopen-procedure') }
|
it { expect(rendered).not_to have_css('button#reopen-procedure') }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -27,9 +27,9 @@ describe 'admin/procedures/show.html.haml', type: :view do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'publish button is visible' do
|
describe 'publish button is visible' do
|
||||||
it { expect(rendered).to have_css('a#publish-procedure') }
|
it { expect(rendered).to have_css('button#publish-procedure') }
|
||||||
it { expect(rendered).not_to have_css('button#archive-procedure') }
|
it { expect(rendered).not_to have_css('button#archive-procedure') }
|
||||||
it { expect(rendered).not_to have_css('a#reopen-procedure') }
|
it { expect(rendered).not_to have_css('button#reopen-procedure') }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'procedure path is not customized' do
|
describe 'procedure path is not customized' do
|
||||||
|
@ -46,9 +46,9 @@ describe 'admin/procedures/show.html.haml', type: :view do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'archive button is visible', js: true do
|
describe 'archive button is visible', js: true do
|
||||||
it { expect(rendered).not_to have_css('a#publish-procedure') }
|
it { expect(rendered).not_to have_css('button#publish-procedure') }
|
||||||
it { expect(rendered).to have_css('button#archive-procedure') }
|
it { expect(rendered).to have_css('button#archive-procedure') }
|
||||||
it { expect(rendered).not_to have_css('a#reopen-procedure') }
|
it { expect(rendered).not_to have_css('button#reopen-procedure') }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'procedure link is present' do
|
describe 'procedure link is present' do
|
||||||
|
@ -65,9 +65,9 @@ describe 'admin/procedures/show.html.haml', type: :view do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'Re-enable button is visible' do
|
describe 'Re-enable button is visible' do
|
||||||
it { expect(rendered).not_to have_css('a#publish-procedure') }
|
it { expect(rendered).not_to have_css('button#publish-procedure') }
|
||||||
it { expect(rendered).not_to have_css('button#archive-procedure') }
|
it { expect(rendered).not_to have_css('button#archive-procedure') }
|
||||||
it { expect(rendered).to have_css('a#reopen-procedure') }
|
it { expect(rendered).to have_css('button#reopen-procedure') }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'procedure link is present' do
|
describe 'procedure link is present' do
|
||||||
|
|
Loading…
Reference in a new issue