Remove Gestionnaire.visible_procedures
It is actually the same thing as Gestionnaire.procedures. It already included the procedures with paths as well as the archived procedures, and in production, there were no Gestionnaire for who procedures was returning a different result than visible_procedures (expect for two baddata brouillon procedures with a nil path). In addition, Procedure.path is now nonnull, which means the Procedure.avec_lien scope is pointless. Finally, the current spec showed that the only procedure not visible to the gestion was the one he was not assigned to.
This commit is contained in:
parent
e9c6ed80e4
commit
8fa630d2bb
5 changed files with 3 additions and 33 deletions
|
@ -7,7 +7,7 @@ module Instructeurs
|
|||
|
||||
def index
|
||||
@procedures = current_instructeur
|
||||
.visible_procedures
|
||||
.procedures
|
||||
.with_attached_logo
|
||||
.includes(:defaut_groupe_instructeur)
|
||||
.order(archived_at: :desc, published_at: :desc, created_at: :desc)
|
||||
|
@ -235,7 +235,7 @@ module Instructeurs
|
|||
end
|
||||
|
||||
def redirect_to_avis_if_needed
|
||||
if current_instructeur.visible_procedures.count == 0 && current_instructeur.avis.count > 0
|
||||
if current_instructeur.procedures.count == 0 && current_instructeur.avis.count > 0
|
||||
redirect_to instructeur_avis_index_path
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,10 +24,6 @@ class Instructeur < ApplicationRecord
|
|||
|
||||
has_one :user
|
||||
|
||||
def visible_procedures
|
||||
procedures.merge(Procedure.avec_lien.or(Procedure.archivees))
|
||||
end
|
||||
|
||||
def follow(dossier)
|
||||
begin
|
||||
followed_dossiers << dossier
|
||||
|
|
|
@ -45,7 +45,6 @@ class Procedure < ApplicationRecord
|
|||
scope :by_libelle, -> { order(libelle: :asc) }
|
||||
scope :created_during, -> (range) { where(created_at: range) }
|
||||
scope :cloned_from_library, -> { where(cloned_from_library: true) }
|
||||
scope :avec_lien, -> { where.not(path: nil) }
|
||||
scope :declarative, -> { where.not(declarative_with_state: nil) }
|
||||
|
||||
scope :for_api, -> {
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
- if nav_bar_profile == :instructeur && instructeur_signed_in?
|
||||
- current_url = request.path_info
|
||||
%ul.header-tabs
|
||||
- if current_instructeur.visible_procedures.count > 0
|
||||
- if current_instructeur.procedures.count > 0
|
||||
%li
|
||||
= active_link_to "Démarches", instructeur_procedures_path, active: :inclusive, class: 'tab-link'
|
||||
- if current_instructeur.avis.count > 0
|
||||
|
|
|
@ -12,31 +12,6 @@ describe Instructeur, type: :model do
|
|||
assign(procedure_2)
|
||||
end
|
||||
|
||||
describe '#visible_procedures' do
|
||||
let(:procedure_not_assigned) { create :procedure, administrateur: admin }
|
||||
let(:procedure_with_default_path) { create :procedure, administrateur: admin }
|
||||
let(:procedure_with_custom_path) { 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_with_default_path)
|
||||
assign(procedure_with_custom_path)
|
||||
assign(procedure_archived_manually)
|
||||
assign(procedure_archived_automatically)
|
||||
end
|
||||
|
||||
subject { instructeur.visible_procedures }
|
||||
|
||||
it do
|
||||
expect(subject).not_to include(procedure_not_assigned)
|
||||
expect(subject).to include(procedure_with_default_path)
|
||||
expect(subject).to include(procedure_with_custom_path)
|
||||
expect(subject).to include(procedure_archived_manually)
|
||||
expect(subject).to include(procedure_archived_automatically)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'follow' do
|
||||
let(:dossier) { create :dossier }
|
||||
let(:already_followed_dossier) { create :dossier }
|
||||
|
|
Loading…
Reference in a new issue