2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-03-06 15:51:08 +01:00
|
|
|
describe 'users/dossiers/dossier_actions', type: :view do
|
2019-07-09 14:30:05 +02:00
|
|
|
let(:procedure) { create(:procedure, :published) }
|
2019-03-26 17:55:40 +01:00
|
|
|
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
|
2021-09-07 10:37:42 +02:00
|
|
|
let(:user) { dossier.user }
|
2019-03-26 17:55:40 +01:00
|
|
|
|
2023-03-06 15:51:08 +01:00
|
|
|
subject { render 'users/dossiers/dossier_actions', dossier: dossier, current_user: user }
|
2019-03-26 17:55:40 +01:00
|
|
|
|
2024-07-24 14:54:27 +02:00
|
|
|
it { is_expected.to have_link('Commencer un nouveau dossier', href: commencer_url(path: procedure.path)) }
|
2023-04-03 20:00:52 +02:00
|
|
|
it { is_expected.to have_link('Supprimer le dossier', href: dossier_path(dossier)) }
|
2022-11-24 19:14:25 +01:00
|
|
|
it { is_expected.to have_link('Transférer le dossier', href: transferer_dossier_path(dossier)) }
|
2019-03-26 17:55:40 +01:00
|
|
|
|
2021-12-08 12:27:12 +01:00
|
|
|
context 'when the dossier is termine' do
|
2019-03-26 17:55:40 +01:00
|
|
|
let(:dossier) { create(:dossier, :accepte, procedure: procedure) }
|
2021-12-08 12:27:12 +01:00
|
|
|
it { is_expected.to have_link('Supprimer le dossier') }
|
2019-03-26 17:55:40 +01:00
|
|
|
end
|
|
|
|
|
2019-03-27 11:43:04 +01:00
|
|
|
context 'when the procedure is closed' do
|
2019-11-14 09:43:45 +01:00
|
|
|
let(:procedure) { create(:procedure, :closed) }
|
2024-07-24 14:54:27 +02:00
|
|
|
it { is_expected.not_to have_link('Commencer un nouveau dossier') }
|
2019-03-27 11:43:04 +01:00
|
|
|
end
|
2023-04-21 12:18:27 +02:00
|
|
|
|
|
|
|
context 'when the procedure is closed and replaced' do
|
|
|
|
let(:procedure) { create(:procedure, :closed, replaced_by_procedure: create(:procedure)) }
|
2024-07-24 14:54:27 +02:00
|
|
|
it { is_expected.to have_link('Commencer un nouveau dossier') }
|
2023-04-21 12:18:27 +02:00
|
|
|
end
|
2019-03-26 17:55:40 +01:00
|
|
|
end
|