2019-03-25 10:53:45 +01:00
|
|
|
|
describe 'users/dossiers/show/header.html.haml', type: :view do
|
2018-08-14 15:02:39 +02:00
|
|
|
|
let(:dossier) { create(:dossier, :en_construction, procedure: create(:procedure)) }
|
2022-04-14 11:08:17 +02:00
|
|
|
|
let(:user) { dossier.user }
|
2018-08-14 15:02:39 +02:00
|
|
|
|
|
2018-09-20 14:05:18 +02:00
|
|
|
|
before do
|
2022-04-14 11:08:17 +02:00
|
|
|
|
sign_in user
|
2018-09-20 14:05:18 +02:00
|
|
|
|
end
|
|
|
|
|
|
2019-03-25 10:53:45 +01:00
|
|
|
|
subject! { render 'users/dossiers/show/header.html.haml', dossier: dossier }
|
2018-08-14 15:02:39 +02:00
|
|
|
|
|
|
|
|
|
it 'affiche les informations du dossier' do
|
|
|
|
|
expect(rendered).to have_text(dossier.procedure.libelle)
|
2018-10-08 18:44:19 +02:00
|
|
|
|
expect(rendered).to have_text("Dossier nº #{dossier.id}")
|
2018-08-14 15:02:39 +02:00
|
|
|
|
expect(rendered).to have_text("en construction")
|
|
|
|
|
|
2021-12-24 18:10:50 +01:00
|
|
|
|
expect(rendered).to have_selector("nav.tabs")
|
2018-08-14 15:02:39 +02:00
|
|
|
|
expect(rendered).to have_link("Résumé", href: dossier_path(dossier))
|
2018-08-29 16:57:01 +02:00
|
|
|
|
expect(rendered).to have_link("Demande", href: demande_dossier_path(dossier))
|
2018-08-14 15:02:39 +02:00
|
|
|
|
end
|
2022-03-23 08:03:08 +01:00
|
|
|
|
|
|
|
|
|
context "when the procedure is closed with a dossier en construction" do
|
|
|
|
|
let(:procedure) { create(:procedure, :closed) }
|
|
|
|
|
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
|
|
|
|
|
|
|
|
|
|
it "n'affiche pas de banner" do
|
|
|
|
|
expect(rendered).not_to have_text("La démarche liée à votre dossier est close")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'can download the dossier' do
|
2023-01-05 10:52:46 +01:00
|
|
|
|
expect(rendered).to have_selector('a[title="Tout le dossier"]')
|
2022-03-23 08:03:08 +01:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context "when the procedure is discarded with a dossier en construction" do
|
2022-05-05 15:31:13 +02:00
|
|
|
|
let(:procedure) { create(:procedure, :with_service, :discarded) }
|
2022-03-23 08:03:08 +01:00
|
|
|
|
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
|
|
|
|
|
|
2022-05-23 18:58:44 +02:00
|
|
|
|
before do
|
|
|
|
|
render 'users/dossiers/show/header.html.haml', dossier: dossier
|
|
|
|
|
end
|
|
|
|
|
|
2022-03-23 08:03:08 +01:00
|
|
|
|
it 'affiche que la démarche est supprimée' do
|
|
|
|
|
expect(rendered).to have_text("La démarche liée à votre dossier est supprimée")
|
|
|
|
|
expect(rendered).to have_text("Vous pouvez toujours consulter votre dossier, mais il n’est plus possible de le modifier")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'can download the dossier' do
|
2023-01-05 10:52:46 +01:00
|
|
|
|
expect(rendered).to have_selector('a[title="Tout le dossier"]')
|
2022-03-23 08:03:08 +01:00
|
|
|
|
end
|
2022-05-23 18:58:44 +02:00
|
|
|
|
|
|
|
|
|
it 'does not display a new procedure link' do
|
|
|
|
|
expect(rendered).not_to have_text("Une nouvelle démarche est disponible, consultez-la ici")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context "when the procedure is discarded with a dossier en construction and a replacement procedure" do
|
|
|
|
|
let(:new_procedure) { create(:procedure, :with_service, aasm_state: :publiee) }
|
|
|
|
|
let!(:procedure) { create(:procedure, :with_service, :discarded, replaced_by_procedure_id: new_procedure.id) }
|
|
|
|
|
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
|
|
|
|
|
|
|
|
|
|
before do
|
|
|
|
|
render 'users/dossiers/show/header.html.haml', dossier: dossier
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'affiche que la démarche est supprimée' do
|
|
|
|
|
expect(rendered).to have_text("La démarche liée à votre dossier est supprimée")
|
|
|
|
|
expect(rendered).to have_text("Vous pouvez toujours consulter votre dossier, mais il n’est plus possible de le modifier")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'can download the dossier' do
|
2023-01-05 10:52:46 +01:00
|
|
|
|
expect(rendered).to have_selector('a[title="Tout le dossier"]')
|
2022-05-23 18:58:44 +02:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'displays a new procedure link' do
|
|
|
|
|
expect(rendered).to have_text("Une nouvelle démarche est disponible, consultez-la ici")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'the has_many and belongs_to relations works well' do
|
|
|
|
|
expect(procedure.replaced_by_procedure).to eq(new_procedure)
|
|
|
|
|
expect(new_procedure.replaced_procedures).to eq([procedure])
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context "when the procedure is discarded with a dossier en construction and a replacement procedure is destroyed" do
|
|
|
|
|
let(:new_procedure) { create(:procedure, :with_service, aasm_state: :publiee) }
|
|
|
|
|
let!(:procedure) { create(:procedure, :with_service, :discarded, replaced_by_procedure_id: new_procedure.id) }
|
|
|
|
|
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
|
|
|
|
|
|
|
|
|
|
before do
|
|
|
|
|
new_procedure.destroy!
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'put the old procedure.replaced_by_procedure blank' do
|
|
|
|
|
expect(procedure.replaced_by_procedure).to eq(nil)
|
|
|
|
|
end
|
2022-03-23 08:03:08 +01:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context "when the procedure is discarded with a dossier terminé" do
|
2022-05-05 15:31:13 +02:00
|
|
|
|
let(:procedure) { create(:procedure, :with_service, :discarded) }
|
2022-02-22 16:09:00 +01:00
|
|
|
|
let(:dossier) { create(:dossier, :accepte, procedure: procedure) }
|
2022-03-23 08:03:08 +01:00
|
|
|
|
|
|
|
|
|
it 'affiche que la démarche est supprimée' do
|
|
|
|
|
expect(rendered).to have_text("La démarche liée à votre dossier est supprimée")
|
2022-12-01 13:41:12 +01:00
|
|
|
|
expect(rendered).to have_text("Votre dossier a été traité par l’administration, aucune action n’est possible")
|
2022-03-23 08:03:08 +01:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'can download the dossier' do
|
2023-01-05 10:52:46 +01:00
|
|
|
|
expect(rendered).to have_selector('a[title="Tout le dossier"]')
|
2022-03-23 08:03:08 +01:00
|
|
|
|
end
|
|
|
|
|
end
|
2022-04-14 11:08:17 +02:00
|
|
|
|
|
|
|
|
|
context "when user is invited" do
|
|
|
|
|
context "when the procedure is closed with a dossier en construction" do
|
|
|
|
|
let(:procedure) { create(:procedure, :closed) }
|
|
|
|
|
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
|
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
|
|
before do
|
|
|
|
|
create(:invite, user: user, dossier: dossier)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "n'affiche pas de banner" do
|
|
|
|
|
expect(rendered).not_to have_text("La démarche liée à votre dossier est close")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'can not download the dossier' do
|
2023-01-05 10:52:46 +01:00
|
|
|
|
expect(rendered).not_to have_selector('a[title="Tout le dossier"]')
|
2022-04-14 11:08:17 +02:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2018-08-14 15:02:39 +02:00
|
|
|
|
end
|