demarches-normaliennes/spec/views/users/dossiers/show/_header.html.haml_spec.rb
Kara Diaby 5f6f19871f tests
2022-05-06 09:04:15 +02:00

81 lines
3 KiB
Ruby
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

describe 'users/dossiers/show/header.html.haml', type: :view do
let(:dossier) { create(:dossier, :en_construction, procedure: create(:procedure)) }
let(:user) { dossier.user }
before do
sign_in user
end
subject! { render 'users/dossiers/show/header.html.haml', dossier: dossier }
it 'affiche les informations du dossier' do
expect(rendered).to have_text(dossier.procedure.libelle)
expect(rendered).to have_text("Dossier nº #{dossier.id}")
expect(rendered).to have_text("en construction")
expect(rendered).to have_selector("nav.tabs")
expect(rendered).to have_link("Résumé", href: dossier_path(dossier))
expect(rendered).to have_link("Demande", href: demande_dossier_path(dossier))
end
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
expect(rendered).to have_text("Tout le dossier")
end
end
context "when the procedure is discarded with a dossier en construction" do
let(:procedure) { create(:procedure, :with_service, :discarded) }
let(:dossier) { create(:dossier, :en_construction, procedure: procedure) }
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 nest plus possible de le modifier")
end
it 'can download the dossier' do
expect(rendered).to have_text("Tout le dossier")
end
end
context "when the procedure is discarded with a dossier terminé" do
let(:procedure) { create(:procedure, :with_service, :discarded) }
let(:dossier) { create(:dossier, :accepte, procedure: procedure) }
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("Votre dossier a été traité par l'administration, aucune action n'est possible")
end
it 'can download the dossier' do
expect(rendered).to have_text("Tout le dossier")
end
end
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
expect(rendered).not_to have_text("Tout le dossier")
end
end
end
end