Merge pull request #3111 from betagouv/instructeur-see-draft-demarches
Affiche les démarches en test dans la liste des Instructeurs
This commit is contained in:
commit
fdf4509573
3 changed files with 43 additions and 7 deletions
|
@ -19,11 +19,7 @@ class Gestionnaire < ApplicationRecord
|
||||||
has_many :dossiers_from_avis, through: :avis, source: :dossier
|
has_many :dossiers_from_avis, through: :avis, source: :dossier
|
||||||
|
|
||||||
def visible_procedures
|
def visible_procedures
|
||||||
if Flipflop.publish_draft?
|
procedures.merge(Procedure.avec_lien.or(Procedure.archivees))
|
||||||
procedures.avec_lien
|
|
||||||
else
|
|
||||||
procedures.publiees_ou_archivees
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_view_dossier?(dossier_id)
|
def can_view_dossier?(dossier_id)
|
||||||
|
|
|
@ -134,6 +134,15 @@ FactoryBot.define do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
trait :archived_automatically do
|
||||||
|
# For now the behavior is the same than :archived
|
||||||
|
# (it may be different in the future though)
|
||||||
|
after(:build) do |procedure, _evaluator|
|
||||||
|
procedure.publish!(generate(:published_path))
|
||||||
|
procedure.archive!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
trait :hidden do
|
trait :hidden do
|
||||||
after(:build) do |procedure, _evaluator|
|
after(:build) do |procedure, _evaluator|
|
||||||
procedure.publish!(generate(:published_path))
|
procedure.publish!(generate(:published_path))
|
||||||
|
|
|
@ -6,10 +6,35 @@ describe Gestionnaire, type: :model do
|
||||||
let!(:procedure_2) { create :procedure, :published, administrateur: admin }
|
let!(:procedure_2) { create :procedure, :published, administrateur: admin }
|
||||||
let!(:procedure_3) { create :procedure, :published, administrateur: admin }
|
let!(:procedure_3) { create :procedure, :published, administrateur: admin }
|
||||||
let(:gestionnaire) { create :gestionnaire, administrateurs: [admin] }
|
let(:gestionnaire) { create :gestionnaire, administrateurs: [admin] }
|
||||||
let!(:procedure_assign) { create :assign_to, gestionnaire: gestionnaire, procedure: procedure }
|
let!(:procedure_assign) { assign(procedure) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_2
|
assign(procedure_2)
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#visible_procedures' do
|
||||||
|
let(:procedure_not_assigned) { create :procedure, administrateur: admin }
|
||||||
|
let(:procedure_without_link) { create :procedure, administrateur: admin }
|
||||||
|
let(:procedure_with_link) { create :procedure, :with_path, administrateur: admin }
|
||||||
|
let(:procedure_archived_manually) { create :procedure, :archived, administrateur: admin }
|
||||||
|
let(:procedure_archived_automatically) { create :procedure, :archived_automatically, administrateur: admin }
|
||||||
|
|
||||||
|
before do
|
||||||
|
assign(procedure_without_link)
|
||||||
|
assign(procedure_with_link)
|
||||||
|
assign(procedure_archived_manually)
|
||||||
|
assign(procedure_archived_automatically)
|
||||||
|
end
|
||||||
|
|
||||||
|
subject { gestionnaire.visible_procedures }
|
||||||
|
|
||||||
|
it do
|
||||||
|
expect(subject).not_to include(procedure_not_assigned)
|
||||||
|
expect(subject).not_to include(procedure_without_link)
|
||||||
|
expect(subject).to include(procedure_with_link)
|
||||||
|
expect(subject).to include(procedure_archived_manually)
|
||||||
|
expect(subject).to include(procedure_archived_automatically)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'follow' do
|
describe 'follow' do
|
||||||
|
@ -390,4 +415,10 @@ describe Gestionnaire, type: :model do
|
||||||
it { expect(follow.demande_seen_at).to eq(freeze_date) }
|
it { expect(follow.demande_seen_at).to eq(freeze_date) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def assign(procedure_to_assign)
|
||||||
|
create :assign_to, gestionnaire: gestionnaire, procedure: procedure_to_assign
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue