remove dossier.linked_dossiers

This commit is contained in:
Paul Chavard 2020-02-11 17:38:04 +01:00
parent 0d55743d9f
commit 7afeae1408
4 changed files with 4 additions and 7 deletions

View file

@ -584,10 +584,6 @@ class Dossier < ApplicationRecord
!PiecesJustificativesService.liste_pieces_justificatives(self).empty? && PiecesJustificativesService.pieces_justificatives_total_size(self) < Dossier::TAILLE_MAX_ZIP
end
def linked_dossiers
Dossier.where(id: champs.filter(&:dossier_link?).map(&:value).compact)
end
def linked_dossiers_for(instructeur)
dossier_ids = champs.filter(&:dossier_link?).map(&:value).compact
(instructeur.dossiers.where(id: dossier_ids) + instructeur.dossiers_from_avis.where(id: dossier_ids)).uniq

View file

@ -204,7 +204,7 @@ describe Instructeurs::AvisController, type: :controller do
context 'and the expert can access the linked dossiers' do
let(:created_avis) { Avis.last(2).first }
let(:linked_avis) { Avis.last }
let(:linked_dossier) { dossier.reload.linked_dossiers.first }
let(:linked_dossier) { Dossier.find_by(id: dossier.reload.champs.filter(&:dossier_link?).map(&:value).compact) }
let(:invite_linked_dossiers) do
instructeur.assign_to_procedure(linked_dossier.procedure)
true

View file

@ -495,7 +495,7 @@ describe Instructeurs::DossiersController, type: :controller do
context 'and the expert can access the linked dossiers' do
let(:saved_avis) { Avis.last(2).first }
let(:linked_avis) { Avis.last }
let(:linked_dossier) { dossier.reload.linked_dossiers.first }
let(:linked_dossier) { Dossier.find_by(id: dossier.reload.champs.filter(&:dossier_link?).map(&:value).compact) }
let(:invite_linked_dossiers) do
instructeur.assign_to_procedure(linked_dossier.procedure)
true

View file

@ -9,11 +9,12 @@ feature 'Inviting an expert:' do
let(:expert_password) { 'mot de passe dexpert' }
let(:procedure) { create(:procedure, :published, instructeurs: [instructeur]) }
let(:dossier) { create(:dossier, :en_construction, :with_dossier_link, procedure: procedure) }
let(:linked_dossier) { Dossier.find_by(id: dossier.reload.champs.filter(&:dossier_link?).map(&:value).compact) }
context 'as an Instructeur' do
scenario 'I can invite an expert' do
# assign instructeur to linked dossier
instructeur.assign_to_procedure(dossier.reload.linked_dossiers.first.procedure)
instructeur.assign_to_procedure(linked_dossier.procedure)
login_as instructeur.user, scope: :user
visit instructeur_dossier_path(procedure, dossier)