diff --git a/app/models/form/setup/questions/scheme_id.rb b/app/models/form/setup/questions/scheme_id.rb index a0a9a076f..6317e4c9d 100644 --- a/app/models/form/setup/questions/scheme_id.rb +++ b/app/models/form/setup/questions/scheme_id.rb @@ -21,7 +21,7 @@ class Form::Setup::Questions::SchemeId < ::Form::Question def displayed_answer_options(case_log) organisation = case_log.owning_organisation || case_log.created_by&.organisation - schemes = organisation ? Scheme.select(:id).where(owning_organisation_id: organisation.id).where.not(managing_organisation_id: nil) : Scheme.select(:id).where.not(managing_organisation_id: nil) + schemes = organisation ? Scheme.select(:id).where(owning_organisation_id: organisation.id).where(confirmed: true) : Scheme.select(:id).where(confirmed: true) filtered_scheme_ids = schemes.joins(:locations).merge(Location.where("startdate <= ? or startdate IS NULL", Time.zone.today)).map(&:id) answer_options.select do |k, _v| filtered_scheme_ids.include?(k.to_i) || k.blank? diff --git a/spec/features/schemes_spec.rb b/spec/features/schemes_spec.rb index d3d9ac321..f1b8aafde 100644 --- a/spec/features/schemes_spec.rb +++ b/spec/features/schemes_spec.rb @@ -888,7 +888,7 @@ RSpec.describe "Schemes scheme Features" do end it "does display the schemes that are not completed" do - schemes[2].update!(managing_organisation_id: nil) + schemes[2].update!(confirmed: false) visit("/logs/#{case_log.id}/scheme") expect(find("#case-log-scheme-id-field").all("option").count).to eq(3) end diff --git a/spec/requests/schemes_controller_spec.rb b/spec/requests/schemes_controller_spec.rb index 7e1909aed..ed553f203 100644 --- a/spec/requests/schemes_controller_spec.rb +++ b/spec/requests/schemes_controller_spec.rb @@ -1078,6 +1078,7 @@ RSpec.describe SchemesController, type: :request do expect(scheme_to_update.reload.scheme_type).to eq("Foyer") expect(scheme_to_update.reload.sensitive).to eq("Yes") expect(scheme_to_update.reload.registered_under_care_act).to eq("No") + expect(scheme_to_update.reload.managing_organisation_id).to eq(scheme_to_update.owning_organisation_id) end end end