Browse Source

Rebase changes

pull/1392/head
Kat 3 years ago
parent
commit
a82c4f2a79
  1. 2
      app/models/form/lettings/questions/la.rb
  2. 2
      app/models/form/lettings/questions/prevloc.rb
  3. 2
      app/models/form/sales/questions/prevloc.rb
  4. 2
      app/models/form/sales/questions/property_local_authority.rb
  5. 2
      app/models/local_authority.rb
  6. 2
      app/models/location.rb
  7. 2
      spec/models/form/lettings/questions/la_spec.rb
  8. 4
      spec/models/form/sales/questions/property_local_authority_spec.rb
  9. 4
      spec/models/location_spec.rb

2
app/models/form/lettings/questions/la.rb

@ -10,6 +10,6 @@ class Form::Lettings::Questions::La < ::Form::Question
end end
def answer_options 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
end end

2
app/models/form/lettings/questions/prevloc.rb

@ -11,6 +11,6 @@ class Form::Lettings::Questions::Prevloc < ::Form::Question
end end
def answer_options 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
end end

2
app/models/form/sales/questions/prevloc.rb

@ -14,6 +14,6 @@ class Form::Sales::Questions::Prevloc < ::Form::Question
end end
def answer_options 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
end end

2
app/models/form/sales/questions/property_local_authority.rb

@ -8,6 +8,6 @@ class Form::Sales::Questions::PropertyLocalAuthority < ::Form::Question
end end
def answer_options 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
end end

2
app/models/local_authority.rb

@ -1,4 +1,4 @@
class LocalAuthority < ApplicationRecord class LocalAuthority < ApplicationRecord
scope :active, ->(date) { where("start_date <= ? AND (end_date IS NULL OR end_date >= ?)", date, date) } 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 end

2
app/models/location.rb

@ -28,7 +28,7 @@ class Location < ApplicationRecord
enum local_authorities: LOCAL_AUTHORITIES enum local_authorities: LOCAL_AUTHORITIES
def self.local_authorities_for_current_year 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 end
MOBILITY_TYPE = { MOBILITY_TYPE = {

2
spec/models/form/lettings/questions/la_spec.rb

@ -312,8 +312,6 @@ RSpec.describe Form::Lettings::Questions::La, type: :model do
"E09000032" => "Wandsworth", "E09000032" => "Wandsworth",
"E09000033" => "Westminster", "E09000033" => "Westminster",
"E06000064" => "Westmorland and Furness", "E06000064" => "Westmorland and Furness",
"S12000017" => "Highland",
"W06000002" => "Gwynedd",
"E06000065" => "North Yorkshire", "E06000065" => "North Yorkshire",
}) })
end end

4
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", "E09000031" => "Waltham Forest",
"E09000032" => "Wandsworth", "E09000032" => "Wandsworth",
"E09000033" => "Westminster", "E09000033" => "Westminster",
"S12000017" => "Highland",
"W06000002" => "Gwynedd",
}) })
end end
end end
@ -669,8 +667,6 @@ RSpec.describe Form::Sales::Questions::PropertyLocalAuthority, type: :model do
"E09000032" => "Wandsworth", "E09000032" => "Wandsworth",
"E09000033" => "Westminster", "E09000033" => "Westminster",
"E06000064" => "Westmorland and Furness", "E06000064" => "Westmorland and Furness",
"S12000017" => "Highland",
"W06000002" => "Gwynedd",
"E06000065" => "North Yorkshire", "E06000065" => "North Yorkshire",
}) })
end end

4
spec/models/location_spec.rb

@ -181,7 +181,6 @@ RSpec.describe Location, type: :model do
"E07000145" => "Great Yarmouth", "E07000145" => "Great Yarmouth",
"E09000011" => "Greenwich", "E09000011" => "Greenwich",
"E07000209" => "Guildford", "E07000209" => "Guildford",
"W06000002" => "Gwynedd",
"E09000012" => "Hackney", "E09000012" => "Hackney",
"E06000006" => "Halton", "E06000006" => "Halton",
"E07000164" => "Hambleton", "E07000164" => "Hambleton",
@ -199,7 +198,6 @@ RSpec.describe Location, type: :model do
"E06000019" => "Herefordshire, County of", "E06000019" => "Herefordshire, County of",
"E07000098" => "Hertsmere", "E07000098" => "Hertsmere",
"E07000037" => "High Peak", "E07000037" => "High Peak",
"S12000017" => "Highland",
"E09000017" => "Hillingdon", "E09000017" => "Hillingdon",
"E07000132" => "Hinckley and Bosworth", "E07000132" => "Hinckley and Bosworth",
"E07000227" => "Horsham", "E07000227" => "Horsham",
@ -509,7 +507,6 @@ RSpec.describe Location, type: :model do
"E07000145" => "Great Yarmouth", "E07000145" => "Great Yarmouth",
"E09000011" => "Greenwich", "E09000011" => "Greenwich",
"E07000209" => "Guildford", "E07000209" => "Guildford",
"W06000002" => "Gwynedd",
"E09000012" => "Hackney", "E09000012" => "Hackney",
"E06000006" => "Halton", "E06000006" => "Halton",
"E09000013" => "Hammersmith and Fulham", "E09000013" => "Hammersmith and Fulham",
@ -525,7 +522,6 @@ RSpec.describe Location, type: :model do
"E06000019" => "Herefordshire, County of", "E06000019" => "Herefordshire, County of",
"E07000098" => "Hertsmere", "E07000098" => "Hertsmere",
"E07000037" => "High Peak", "E07000037" => "High Peak",
"S12000017" => "Highland",
"E09000017" => "Hillingdon", "E09000017" => "Hillingdon",
"E07000132" => "Hinckley and Bosworth", "E07000132" => "Hinckley and Bosworth",
"E07000227" => "Horsham", "E07000227" => "Horsham",

Loading…
Cancel
Save