From a4bdbacd897075df150341e294e67c4fade471c2 Mon Sep 17 00:00:00 2001 From: Kat Date: Mon, 25 Jul 2022 09:11:14 +0100 Subject: [PATCH] Revert "convert to use values that won't change for checks" because the value coming through from the params is the value and not a key This reverts commit 50053ec0cf233e3a6c36db9af2528c354d3d60e7. --- app/controllers/schemes_controller.rb | 6 +++--- app/models/scheme.rb | 2 +- spec/features/schemes_spec.rb | 2 +- spec/requests/schemes_controller_spec.rb | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/schemes_controller.rb b/app/controllers/schemes_controller.rb index a7cb487ca..91f0420b6 100644 --- a/app/controllers/schemes_controller.rb +++ b/app/controllers/schemes_controller.rb @@ -104,7 +104,7 @@ private end end - if @scheme.arrangement_type_same? && scheme_params[:arrangement_type] != "D" + if @scheme.arrangement_type_same? && scheme_params[:arrangement_type] != "The same organisation that owns the housing stock" @scheme.errors.delete(:managing_organisation_id) end end @@ -191,11 +191,11 @@ private end def arrangement_type_set_to_same_org?(required_params) - required_params[:arrangement_type] == "D" || (required_params[:arrangement_type].blank? && @scheme.present? && @scheme.arrangement_type_same?) + required_params[:arrangement_type] == "The same organisation that owns the housing stock" || (required_params[:arrangement_type].blank? && @scheme.present? && @scheme.arrangement_type_same?) end def arrangement_type_changed_to_different_org?(required_params) - @scheme.present? && @scheme.arrangement_type_same? && required_params[:arrangement_type] != "D" && required_params[:managing_organisation_id].blank? + @scheme.present? && @scheme.arrangement_type_same? && required_params[:arrangement_type] != "The same organisation that owns the housing stock" && required_params[:managing_organisation_id].blank? end def search_term diff --git a/app/models/scheme.rb b/app/models/scheme.rb index 601239305..3ad3639f1 100644 --- a/app/models/scheme.rb +++ b/app/models/scheme.rb @@ -203,6 +203,6 @@ class Scheme < ApplicationRecord end def arrangement_type_same? - arrangement_type_before_type_cast == "D" + arrangement_type == "The same organisation that owns the housing stock" end end diff --git a/spec/features/schemes_spec.rb b/spec/features/schemes_spec.rb index 290598d79..d3d9ac321 100644 --- a/spec/features/schemes_spec.rb +++ b/spec/features/schemes_spec.rb @@ -843,7 +843,7 @@ RSpec.describe "Schemes scheme Features" do context "when selecting a scheme" do let!(:user) { FactoryBot.create(:user, :data_coordinator, last_sign_in_at: Time.zone.now) } - let!(:schemes) { FactoryBot.create_list(:scheme, 5, owning_organisation: user.organisation, managing_organisation: user.organisation, arrangement_type: "D") } + let!(:schemes) { FactoryBot.create_list(:scheme, 5, owning_organisation: user.organisation, managing_organisation: user.organisation, arrangement_type: "The same organisation that owns the housing stock") } let(:location) { FactoryBot.create(:location, scheme: schemes[2]) } let!(:case_log) { FactoryBot.create(:case_log, created_by: user, needstype: 2) } diff --git a/spec/requests/schemes_controller_spec.rb b/spec/requests/schemes_controller_spec.rb index 3a30ecfa8..7e1909aed 100644 --- a/spec/requests/schemes_controller_spec.rb +++ b/spec/requests/schemes_controller_spec.rb @@ -1043,7 +1043,7 @@ RSpec.describe SchemesController, type: :request do scheme_type: "Foyer", registered_under_care_act: "No", page: "details", - arrangement_type: "D", + arrangement_type: "The same organisation that owns the housing stock", owning_organisation_id: another_organisation.id } } end