2023-03-06 15:51:08 +01:00
|
|
|
|
describe 'administrateurs/procedures/show', type: :view do
|
2020-09-08 12:35:44 +02:00
|
|
|
|
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))
|
2021-06-24 11:57:05 +02:00
|
|
|
|
assign(:procedure_lien_test, commencer_test_url(path: procedure.path))
|
2020-09-24 14:36:22 +02:00
|
|
|
|
allow(view).to receive(:current_administrateur).and_return(procedure.administrateurs.first)
|
2020-09-08 12:35:44 +02:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe 'procedure is draft' do
|
|
|
|
|
context 'when procedure have a instructeur affected' do
|
|
|
|
|
before do
|
|
|
|
|
create(:instructeur).assign_to_procedure(procedure)
|
|
|
|
|
render
|
|
|
|
|
end
|
|
|
|
|
|
2024-07-03 14:09:08 +02:00
|
|
|
|
it "render content" do
|
|
|
|
|
expect(rendered).to have_css('#publish-procedure-link')
|
|
|
|
|
expect(rendered).not_to have_css('#close-procedure-link')
|
|
|
|
|
expect(rendered).to have_content('En test')
|
|
|
|
|
expect(rendered).not_to have_css('#archive-procedure')
|
2022-06-23 13:51:58 +02:00
|
|
|
|
end
|
2020-09-08 12:35:44 +02:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe 'procedure is published' do
|
|
|
|
|
before do
|
|
|
|
|
procedure.publish!
|
|
|
|
|
procedure.reload
|
|
|
|
|
render
|
|
|
|
|
end
|
|
|
|
|
|
2021-10-19 16:23:08 +02:00
|
|
|
|
describe 'archive button is visible' do
|
2020-09-08 12:35:44 +02:00
|
|
|
|
it { expect(rendered).not_to have_css('#publish-procedure-link') }
|
|
|
|
|
it { expect(rendered).to have_css('#close-procedure-link') }
|
|
|
|
|
end
|
2022-06-23 13:51:58 +02:00
|
|
|
|
describe 'archive button' do
|
|
|
|
|
it { expect(rendered).to have_css('#archive-procedure') }
|
|
|
|
|
end
|
2020-09-08 12:35:44 +02:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe 'procedure is closed' do
|
|
|
|
|
before do
|
|
|
|
|
procedure.publish!
|
|
|
|
|
procedure.close!
|
|
|
|
|
procedure.reload
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe 'Re-enable button is visible' do
|
2020-12-18 09:16:41 +01:00
|
|
|
|
before do
|
|
|
|
|
render
|
|
|
|
|
end
|
|
|
|
|
|
2020-09-08 12:35:44 +02:00
|
|
|
|
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
|
2022-02-22 16:09:00 +01:00
|
|
|
|
|
|
|
|
|
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
|
2020-09-08 12:35:44 +02:00
|
|
|
|
end
|