2017-12-12 16:44:30 +01:00
|
|
|
describe DossierLinkHelper do
|
|
|
|
describe "#dossier_linked_path" do
|
2019-08-06 11:02:54 +02:00
|
|
|
context "when no access as a instructeur" do
|
|
|
|
let(:instructeur) { create(:instructeur) }
|
2017-12-12 16:44:30 +01:00
|
|
|
let(:dossier) { create(:dossier) }
|
|
|
|
|
2019-08-06 11:02:54 +02:00
|
|
|
it { expect(helper.dossier_linked_path(instructeur, dossier)).to be_nil }
|
2017-12-12 16:44:30 +01:00
|
|
|
end
|
|
|
|
|
2018-12-28 17:22:51 +01:00
|
|
|
context "when no access as a user" do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:dossier) { create(:dossier) }
|
|
|
|
|
|
|
|
it { expect(helper.dossier_linked_path(user, dossier)).to be_nil }
|
|
|
|
end
|
|
|
|
|
2019-08-06 11:02:54 +02:00
|
|
|
context "when access as instructeur" do
|
2018-01-15 22:10:46 +01:00
|
|
|
let(:dossier) { create(:dossier) }
|
2019-08-06 11:02:54 +02:00
|
|
|
let(:instructeur) { create(:instructeur) }
|
2017-12-12 16:44:30 +01:00
|
|
|
|
2019-08-21 14:09:56 +02:00
|
|
|
before { dossier.procedure.defaut_groupe_instructeur.instructeurs << instructeur }
|
2017-12-12 16:44:30 +01:00
|
|
|
|
2019-08-06 11:02:54 +02:00
|
|
|
it { expect(helper.dossier_linked_path(instructeur, dossier)).to eq(instructeur_dossier_path(dossier.procedure, dossier)) }
|
2017-12-12 16:44:30 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
context "when access as expert" do
|
2018-01-15 22:10:46 +01:00
|
|
|
let(:dossier) { create(:dossier) }
|
2019-08-06 11:02:54 +02:00
|
|
|
let(:instructeur) { create(:instructeur) }
|
|
|
|
let!(:avis) { create(:avis, dossier: dossier, instructeur: instructeur) }
|
2017-12-12 16:44:30 +01:00
|
|
|
|
2019-08-06 11:02:54 +02:00
|
|
|
it { expect(helper.dossier_linked_path(instructeur, dossier)).to eq(instructeur_avis_path(avis)) }
|
2017-12-12 16:44:30 +01:00
|
|
|
end
|
2018-12-28 17:22:51 +01:00
|
|
|
|
|
|
|
context "when access as user" do
|
|
|
|
let(:dossier) { create(:dossier) }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before { dossier.user = user }
|
|
|
|
|
|
|
|
it { expect(helper.dossier_linked_path(user, dossier)).to eq(dossier_path(dossier)) }
|
|
|
|
end
|
2017-12-12 16:44:30 +01:00
|
|
|
end
|
|
|
|
end
|