2017-12-12 16:44:30 +01:00
|
|
|
describe DossierLinkHelper do
|
|
|
|
describe "#dossier_linked_path" do
|
|
|
|
context "when no access" do
|
|
|
|
let(:gestionnaire) { create(:gestionnaire) }
|
|
|
|
let(:dossier) { create(:dossier) }
|
|
|
|
|
|
|
|
it { expect(helper.dossier_linked_path(gestionnaire, dossier)).to be_nil }
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when access as gestionnaire" do
|
2018-01-15 22:10:46 +01:00
|
|
|
let(:dossier) { create(:dossier) }
|
2017-12-12 16:44:30 +01:00
|
|
|
let(:gestionnaire) { create(:gestionnaire) }
|
|
|
|
|
|
|
|
before { dossier.procedure.gestionnaires << gestionnaire }
|
|
|
|
|
2018-02-21 14:40:41 +01:00
|
|
|
it { expect(helper.dossier_linked_path(gestionnaire, dossier)).to eq(gestionnaire_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) }
|
2017-12-12 16:44:30 +01:00
|
|
|
let(:gestionnaire) { create(:gestionnaire) }
|
|
|
|
let!(:avis) { create(:avis, dossier: dossier, gestionnaire: gestionnaire) }
|
|
|
|
|
2018-02-21 15:19:04 +01:00
|
|
|
it { expect(helper.dossier_linked_path(gestionnaire, dossier)).to eq(gestionnaire_avis_path(avis)) }
|
2017-12-12 16:44:30 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|