display procedures without zones

This commit is contained in:
Christophe Robillard 2023-02-24 17:27:28 +01:00
parent d0e05784e9
commit 1d6c2fd7eb
2 changed files with 11 additions and 1 deletions

View file

@ -410,7 +410,7 @@ module Administrateurs
private
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(aasm_state: filter.statuses) if filter.statuses.present?
procedures_result = procedures_result.where("? = ANY(tags)", filter.tag) if filter.tag.present?

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 == procedure1.id }).to be_falsey
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
context 'for specific status' do