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
|
2019-10-23 19:43:37 +02:00
|
|
|
let(:procedure) { create(:procedure, :routee) }
|
|
|
|
let(:dossier) { create(:dossier, groupe_instructeur: procedure.groupe_instructeurs.last) }
|
2019-08-06 11:02:54 +02:00
|
|
|
let(:instructeur) { create(:instructeur) }
|
2017-12-12 16:44:30 +01:00
|
|
|
|
2019-10-23 19:43:37 +02:00
|
|
|
before { procedure.groupe_instructeurs.last.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
|
|
|
|
|
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
|