Merge pull request #8706 from demarches-simplifiees/all_demarches_even_without_zones

liste toutes les démarches, même celles non associées à des zones
This commit is contained in:
krichtof 2023-02-28 10:58:07 +00:00 committed by GitHub
commit dee499d386
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 2 deletions

View file

@ -410,7 +410,7 @@ module Administrateurs
private private
def filter_procedures(filter) def filter_procedures(filter)
procedures_result = Procedure.select(:id).joins(:procedures_zones).distinct.publiees_ou_closes procedures_result = Procedure.select(:id).left_joins(:procedures_zones).distinct.publiees_ou_closes
procedures_result = procedures_result.where(procedures_zones: { zone_id: filter.zone_ids }) if filter.zone_ids.present? procedures_result = procedures_result.where(procedures_zones: { zone_id: filter.zone_ids }) if filter.zone_ids.present?
procedures_result = procedures_result.where(aasm_state: filter.statuses) if filter.statuses.present? procedures_result = procedures_result.where(aasm_state: filter.statuses) if filter.statuses.present?
procedures_result = procedures_result.where("? = ANY(tags)", filter.tag) if filter.tag.present? procedures_result = procedures_result.where("? = ANY(tags)", filter.tag) if filter.tag.present?

View file

@ -11,7 +11,7 @@
%td= procedure.estimated_dossiers_count %td= procedure.estimated_dossiers_count
%td= procedure.administrateurs.count %td= procedure.administrateurs.count
%td= t procedure.aasm_state, scope: 'activerecord.attributes.procedure.aasm_state' %td= t procedure.aasm_state, scope: 'activerecord.attributes.procedure.aasm_state'
%td= l(procedure.published_at, format: :message_date_without_time) %td= l(procedure.published_at, format: :message_date_without_time) if procedure.published_at
%td= link_to('Cloner', admin_procedure_clone_path(procedure.id, from_new_from_existing: true), 'data-method' => :put, class: 'fr-btn fr-btn--tertiary fr-btn--sm') %td= link_to('Cloner', admin_procedure_clone_path(procedure.id, from_new_from_existing: true), 'data-method' => :put, class: 'fr-btn fr-btn--tertiary fr-btn--sm')

View file

@ -132,6 +132,16 @@ describe Administrateurs::ProceduresController, type: :controller do
expect(assigns(:procedures).any? { |p| p.id == procedure2.id }).to be_truthy expect(assigns(:procedures).any? { |p| p.id == procedure2.id }).to be_truthy
expect(assigns(:procedures).any? { |p| p.id == procedure1.id }).to be_falsey expect(assigns(:procedures).any? { |p| p.id == procedure1.id }).to be_falsey
end end
context "without zones" do
let!(:procedure) { create(:procedure, :published, zones: []) }
subject { get :all }
it 'displays procedures without zones' do
subject
expect(assigns(:procedures).any? { |p| p.id == procedure.id }).to be_truthy
end
end
end end
context 'for specific status' do context 'for specific status' do