From 2442c8be85085979fbfdcd726a69dca4991144db Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Tue, 10 Oct 2023 14:18:18 +0100 Subject: [PATCH] Ensure the right applications appear in case management --- app/models/application_form.rb | 16 ++++++++++------ .../listing_application_forms_spec.rb | 1 + 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/models/application_form.rb b/app/models/application_form.rb index 80bd8a486e..e7d79622ec 100644 --- a/app/models/application_form.rb +++ b/app/models/application_form.rb @@ -198,12 +198,16 @@ class ApplicationForm < ApplicationRecord scope :active, -> do - assessable - .or(awarded_pending_checks) - .or(potential_duplicate_in_dqt) - .or(awarded.where("awarded_at >= ?", 90.days.ago)) - .or(declined.where("declined_at >= ?", 90.days.ago)) - .or(withdrawn.where("withdrawn_at >= ?", 90.days.ago)) + joins(region: :country) + .where.not(countries: { code: "ZW" }) + .merge( + assessable + .or(awarded_pending_checks) + .or(potential_duplicate_in_dqt) + .or(awarded.where("awarded_at >= ?", 90.days.ago)) + .or(declined.where("declined_at >= ?", 90.days.ago)) + .or(withdrawn.where("withdrawn_at >= ?", 90.days.ago)), + ) end scope :destroyable, diff --git a/spec/system/assessor_interface/listing_application_forms_spec.rb b/spec/system/assessor_interface/listing_application_forms_spec.rb index ec096abb64..b8d8d61f52 100644 --- a/spec/system/assessor_interface/listing_application_forms_spec.rb +++ b/spec/system/assessor_interface/listing_application_forms_spec.rb @@ -65,6 +65,7 @@ def application_forms 25, :with_personal_information, :submitted, + region: create(:region, :in_country, country_code: "FR"), ).sort_by(&:submitted_at) end end