From a82c4f2a79e0ecd1014b0e3611dc304c69e37f2a Mon Sep 17 00:00:00 2001 From: Kat Date: Wed, 8 Mar 2023 14:51:45 +0000 Subject: [PATCH] Rebase changes --- app/models/form/lettings/questions/la.rb | 2 +- app/models/form/lettings/questions/prevloc.rb | 2 +- app/models/form/sales/questions/prevloc.rb | 2 +- app/models/form/sales/questions/property_local_authority.rb | 2 +- app/models/local_authority.rb | 2 +- app/models/location.rb | 2 +- spec/models/form/lettings/questions/la_spec.rb | 2 -- .../form/sales/questions/property_local_authority_spec.rb | 4 ---- spec/models/location_spec.rb | 4 ---- 9 files changed, 6 insertions(+), 16 deletions(-) diff --git a/app/models/form/lettings/questions/la.rb b/app/models/form/lettings/questions/la.rb index fb6b046f7..34d5ba2da 100644 --- a/app/models/form/lettings/questions/la.rb +++ b/app/models/form/lettings/questions/la.rb @@ -10,6 +10,6 @@ class Form::Lettings::Questions::La < ::Form::Question end def answer_options - { "" => "Select an option" }.merge(LocalAuthority.active(Time.zone.local(2023, 4, 1)).previous_location(false).map { |la| [la.code, la.la_name] }.to_h) + { "" => "Select an option" }.merge(LocalAuthority.active(Time.zone.local(2023, 4, 1)).england.map { |la| [la.code, la.name] }.to_h) end end diff --git a/app/models/form/lettings/questions/prevloc.rb b/app/models/form/lettings/questions/prevloc.rb index 9f6ab7f46..4e9a7bf2f 100644 --- a/app/models/form/lettings/questions/prevloc.rb +++ b/app/models/form/lettings/questions/prevloc.rb @@ -11,6 +11,6 @@ class Form::Lettings::Questions::Prevloc < ::Form::Question end def answer_options - { "" => "Select an option" }.merge(LocalAuthority.active(Time.zone.local(2023, 4, 1)).map { |la| [la.code, la.la_name] }.to_h) + { "" => "Select an option" }.merge(LocalAuthority.active(Time.zone.local(2023, 4, 1)).map { |la| [la.code, la.name] }.to_h) end end diff --git a/app/models/form/sales/questions/prevloc.rb b/app/models/form/sales/questions/prevloc.rb index b5e2489d3..e7395e749 100644 --- a/app/models/form/sales/questions/prevloc.rb +++ b/app/models/form/sales/questions/prevloc.rb @@ -14,6 +14,6 @@ class Form::Sales::Questions::Prevloc < ::Form::Question end def answer_options - { "" => "Select an option" }.merge(LocalAuthority.active(form.start_date).map { |la| [la.code, la.la_name] }.to_h) + { "" => "Select an option" }.merge(LocalAuthority.active(form.start_date).map { |la| [la.code, la.name] }.to_h) end end diff --git a/app/models/form/sales/questions/property_local_authority.rb b/app/models/form/sales/questions/property_local_authority.rb index 70b7b3eef..7b08a8a08 100644 --- a/app/models/form/sales/questions/property_local_authority.rb +++ b/app/models/form/sales/questions/property_local_authority.rb @@ -8,6 +8,6 @@ class Form::Sales::Questions::PropertyLocalAuthority < ::Form::Question end def answer_options - { "" => "Select an option" }.merge(LocalAuthority.active(form.start_date).previous_location(false).map { |la| [la.code, la.la_name] }.to_h) + { "" => "Select an option" }.merge(LocalAuthority.active(form.start_date).england.map { |la| [la.code, la.name] }.to_h) end end diff --git a/app/models/local_authority.rb b/app/models/local_authority.rb index 2c406f041..22786ce7c 100644 --- a/app/models/local_authority.rb +++ b/app/models/local_authority.rb @@ -1,4 +1,4 @@ class LocalAuthority < ApplicationRecord scope :active, ->(date) { where("start_date <= ? AND (end_date IS NULL OR end_date >= ?)", date, date) } - scope :previous_location, ->(is_previous_la) { where(previous_location_only: is_previous_la) } + scope :england, -> { where("code LIKE ?", "E%") } end diff --git a/app/models/location.rb b/app/models/location.rb index 5c6a3072f..0f90aedf5 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -28,7 +28,7 @@ class Location < ApplicationRecord enum local_authorities: LOCAL_AUTHORITIES def self.local_authorities_for_current_year - LocalAuthority.all.active(Time.zone.today).previous_location(false).map { |la| [la.code, la.la_name] }.to_h + LocalAuthority.all.active(Time.zone.today).england.map { |la| [la.code, la.name] }.to_h end MOBILITY_TYPE = { diff --git a/spec/models/form/lettings/questions/la_spec.rb b/spec/models/form/lettings/questions/la_spec.rb index 16178258a..0451e092e 100644 --- a/spec/models/form/lettings/questions/la_spec.rb +++ b/spec/models/form/lettings/questions/la_spec.rb @@ -312,8 +312,6 @@ RSpec.describe Form::Lettings::Questions::La, type: :model do "E09000032" => "Wandsworth", "E09000033" => "Westminster", "E06000064" => "Westmorland and Furness", - "S12000017" => "Highland", - "W06000002" => "Gwynedd", "E06000065" => "North Yorkshire", }) end diff --git a/spec/models/form/sales/questions/property_local_authority_spec.rb b/spec/models/form/sales/questions/property_local_authority_spec.rb index 854f6d1c9..24b8933a9 100644 --- a/spec/models/form/sales/questions/property_local_authority_spec.rb +++ b/spec/models/form/sales/questions/property_local_authority_spec.rb @@ -355,8 +355,6 @@ RSpec.describe Form::Sales::Questions::PropertyLocalAuthority, type: :model do "E09000031" => "Waltham Forest", "E09000032" => "Wandsworth", "E09000033" => "Westminster", - "S12000017" => "Highland", - "W06000002" => "Gwynedd", }) end end @@ -669,8 +667,6 @@ RSpec.describe Form::Sales::Questions::PropertyLocalAuthority, type: :model do "E09000032" => "Wandsworth", "E09000033" => "Westminster", "E06000064" => "Westmorland and Furness", - "S12000017" => "Highland", - "W06000002" => "Gwynedd", "E06000065" => "North Yorkshire", }) end diff --git a/spec/models/location_spec.rb b/spec/models/location_spec.rb index f2b04beb8..9a5874415 100644 --- a/spec/models/location_spec.rb +++ b/spec/models/location_spec.rb @@ -181,7 +181,6 @@ RSpec.describe Location, type: :model do "E07000145" => "Great Yarmouth", "E09000011" => "Greenwich", "E07000209" => "Guildford", - "W06000002" => "Gwynedd", "E09000012" => "Hackney", "E06000006" => "Halton", "E07000164" => "Hambleton", @@ -199,7 +198,6 @@ RSpec.describe Location, type: :model do "E06000019" => "Herefordshire, County of", "E07000098" => "Hertsmere", "E07000037" => "High Peak", - "S12000017" => "Highland", "E09000017" => "Hillingdon", "E07000132" => "Hinckley and Bosworth", "E07000227" => "Horsham", @@ -509,7 +507,6 @@ RSpec.describe Location, type: :model do "E07000145" => "Great Yarmouth", "E09000011" => "Greenwich", "E07000209" => "Guildford", - "W06000002" => "Gwynedd", "E09000012" => "Hackney", "E06000006" => "Halton", "E09000013" => "Hammersmith and Fulham", @@ -525,7 +522,6 @@ RSpec.describe Location, type: :model do "E06000019" => "Herefordshire, County of", "E07000098" => "Hertsmere", "E07000037" => "High Peak", - "S12000017" => "Highland", "E09000017" => "Hillingdon", "E07000132" => "Hinckley and Bosworth", "E07000227" => "Horsham",