demarches-normaliennes/spec/views/administrateurs/procedures/show.html.haml_spec.rb
Martin 3737311390 feat(procedure.procedure_expires_when_termine_enabled): enable by default, allow contributor to choose the default settings of this flag using an env var during migration. ie: DEFAULT_PROCEDURE_EXPIRES_WHEN_TERMINE_ENABLED=true|false
feat(administrateurs/procedures#show): warning/alert when procedure_expires_when_termine_enabled is not true on current procedure

feat(administrateur/procedure#update): after an update redirect to procedure show: suggested by: https://ux.stackexchange.com/questions/55291/after-updating-form-should-redirect-back-to-form-itself-or-to-the-show-page-or-b and confirmed by Olivier

clean(Flipper.archive_zip_globale): no more in use, so remove all occurences

Update app/views/administrateurs/procedures/_suggest_expires_when_termine.html.haml

Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com>

Update app/views/administrateurs/procedures/_suggest_expires_when_termine.html.haml

Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com>

Update app/views/administrateurs/procedures/_suggest_expires_when_termine.html.haml

Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com>

Update spec/views/administrateurs/procedures/show.html.haml_spec.rb

Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com>

fix(review): typo, why ena?, who knows

fix(env.example.optional): add missing DEFAULT_PROCEDURE_EXPIRES_WHEN_TERMINE_ENABLED
2022-05-05 13:07:11 +02:00

80 lines
2.4 KiB
Ruby

describe 'administrateurs/procedures/show.html.haml', type: :view do
let(:closed_at) { nil }
let(:procedure) { create(:procedure, :with_service, closed_at: closed_at) }
before do
assign(:procedure, procedure)
assign(:procedure_lien, commencer_url(path: procedure.path))
assign(:procedure_lien_test, commencer_test_url(path: procedure.path))
allow(view).to receive(:current_administrateur).and_return(procedure.administrateurs.first)
end
describe 'procedure is draft' do
context 'when procedure have a instructeur affected' do
before do
create(:instructeur).assign_to_procedure(procedure)
render
end
describe 'publish button is visible' do
it { expect(rendered).to have_css('#publish-procedure-link') }
it { expect(rendered).not_to have_css('#close-procedure-link') }
end
describe 'procedure path is not customized' do
it { expect(rendered).to have_content('Brouillon') }
end
end
end
describe 'procedure is published' do
before do
procedure.publish!
procedure.reload
render
end
describe 'archive button is visible' do
it { expect(rendered).not_to have_css('#publish-procedure-link') }
it { expect(rendered).to have_css('#close-procedure-link') }
end
end
describe 'procedure is closed' do
before do
procedure.publish!
procedure.close!
procedure.reload
end
describe 'Re-enable button is visible' do
before do
render
end
it { expect(rendered).not_to have_css('#close-procedure-link') }
it { expect(rendered).to have_css('#publish-procedure-link') }
it { expect(rendered).to have_content('Réactiver') }
end
end
describe 'procedure with expiration disabled' do
let(:procedure) { create(:procedure, procedure_expires_when_termine_enabled: true) }
before do
render
end
it 'does not render partial to enable procedure_expires_when_termine_enabled' do
expect(rendered).not_to have_css("div[data-test-suggest_expires_when_termine]")
end
end
describe 'procedure with expiration enabled' do
let(:procedure) { create(:procedure, procedure_expires_when_termine_enabled: false) }
before do
render
end
it 'renders a partial to enable procedure_expires_when_termine_enabled' do
expect(rendered).to have_css("div[data-test-suggest_expires_when_termine]")
end
end
end