Browse Source

[CLDC-1470] Add wheelchair accessible question (#1145)

* Add missing PropertyLocalAuthority specs

* Add Property Wheelchair Accessible question
pull/1157/head
Jack 2 years ago committed by GitHub
parent
commit
b97ba94964
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      app/models/form/sales/pages/property_wheelchair_accessible.rb
  2. 17
      app/models/form/sales/questions/property_wheelchair_accessible.rb
  3. 1
      app/models/form/sales/subsections/property_information.rb
  4. 7
      db/migrate/20230104152012_add_wchair_to_sales_log.rb
  5. 1
      db/schema.rb
  6. 1
      spec/factories/sales_log.rb
  7. 34
      spec/models/form/sales/pages/property_local_authority_spec.rb
  8. 29
      spec/models/form/sales/pages/property_wheelchair_accessible_spec.rb
  9. 355
      spec/models/form/sales/questions/property_local_authority_spec.rb
  10. 41
      spec/models/form/sales/questions/property_wheelchair_accessible_spec.rb
  11. 1
      spec/models/form/sales/subsections/property_information_spec.rb
  12. 4
      spec/models/form_handler_spec.rb

15
app/models/form/sales/pages/property_wheelchair_accessible.rb

@ -0,0 +1,15 @@
class Form::Sales::Pages::PropertyWheelchairAccessible < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "property_wheelchair_accessible"
@header = ""
@description = ""
@subsection = subsection
end
def questions
@questions ||= [
Form::Sales::Questions::PropertyWheelchairAccessible.new(nil, nil, self),
]
end
end

17
app/models/form/sales/questions/property_wheelchair_accessible.rb

@ -0,0 +1,17 @@
class Form::Sales::Questions::PropertyWheelchairAccessible < ::Form::Question
def initialize(id, hsh, page)
super
@id = "wchair"
@check_answer_label = "Property build or adapted to wheelchair-user standards"
@header = "Is the property build or adapted to wheelchair-user standards?"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@page = page
end
ANSWER_OPTIONS = {
"1" => { "value" => "Yes" },
"2" => { "value" => "No" },
"3" => { "value" => "Don't know" },
}.freeze
end

1
app/models/form/sales/subsections/property_information.rb

@ -13,6 +13,7 @@ class Form::Sales::Subsections::PropertyInformation < ::Form::Subsection
Form::Sales::Pages::PropertyBuildingType.new(nil, nil, self),
Form::Sales::Pages::PropertyUnitType.new(nil, nil, self),
Form::Sales::Pages::PropertyLocalAuthority.new(nil, nil, self),
Form::Sales::Pages::PropertyWheelchairAccessible.new(nil, nil, self),
]
end
end

7
db/migrate/20230104152012_add_wchair_to_sales_log.rb

@ -0,0 +1,7 @@
class AddWchairToSalesLog < ActiveRecord::Migration[7.0]
def change
change_table :sales_logs, bulk: true do |t|
t.column :wchair, :integer
end
end
end

1
db/schema.rb

@ -459,6 +459,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_04_164318) do
t.integer "deposit_value_check"
t.integer "hb"
t.integer "mortgageused"
t.integer "wchair"
t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id"
t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id"
t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id"

1
spec/factories/sales_log.rb

@ -88,6 +88,7 @@ FactoryBot.define do
relat6 { "P" }
hb { 4 }
mortgageused { 1 }
wchair { 1 }
end
end
end

34
spec/models/form/sales/pages/property_local_authority_spec.rb

@ -0,0 +1,34 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::PropertyLocalAuthority, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { nil }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
end
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(
%w[
la_known
la
],
)
end
it "has the correct id" do
expect(page.id).to eq("property_local_authority")
end
it "has the correct header" do
expect(page.header).to eq("")
end
it "has the correct description" do
expect(page.description).to eq("")
end
end

29
spec/models/form/sales/pages/property_wheelchair_accessible_spec.rb

@ -0,0 +1,29 @@
require "rails_helper"
RSpec.describe Form::Sales::Pages::PropertyWheelchairAccessible, type: :model do
subject(:page) { described_class.new(page_id, page_definition, subsection) }
let(:page_id) { nil }
let(:page_definition) { nil }
let(:subsection) { instance_double(Form::Subsection) }
it "has correct subsection" do
expect(page.subsection).to eq(subsection)
end
it "has correct questions" do
expect(page.questions.map(&:id)).to eq(%w[wchair])
end
it "has the correct id" do
expect(page.id).to eq("property_wheelchair_accessible")
end
it "has the correct header" do
expect(page.header).to eq("")
end
it "has the correct description" do
expect(page.description).to eq("")
end
end

355
spec/models/form/sales/questions/property_local_authority_spec.rb

@ -0,0 +1,355 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::PropertyLocalAuthority, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct id" do
expect(question.id).to eq("la")
end
it "has the correct header" do
expect(question.header).to eq("What is the local authority of the property?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Local authority")
end
it "has the correct type" do
expect(question.type).to eq("select")
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"" => "Select an option",
"E06000001" => "Hartlepool",
"E06000002" => "Middlesbrough",
"E06000003" => "Redcar and Cleveland",
"E06000004" => "Stockton-on-Tees",
"E06000005" => "Darlington",
"E06000006" => "Halton",
"E06000007" => "Warrington",
"E06000008" => "Blackburn with Darwen",
"E06000009" => "Blackpool",
"E06000010" => "Kingston upon Hull, City of",
"E06000011" => "East Riding of Yorkshire",
"E06000012" => "North East Lincolnshire",
"E06000013" => "North Lincolnshire",
"E06000014" => "York",
"E06000015" => "Derby",
"E06000016" => "Leicester",
"E06000017" => "Rutland",
"E06000018" => "Nottingham",
"E06000019" => "Herefordshire, County of",
"E06000020" => "Telford and Wrekin",
"E06000021" => "Stoke-on-Trent",
"E06000022" => "Bath and North East Somerset",
"E06000023" => "Bristol, City of",
"E06000024" => "North Somerset",
"E06000025" => "South Gloucestershire",
"E06000026" => "Plymouth",
"E06000027" => "Torbay",
"E06000030" => "Swindon",
"E06000031" => "Peterborough",
"E06000032" => "Luton",
"E06000033" => "Southend-on-Sea",
"E06000034" => "Thurrock",
"E06000035" => "Medway",
"E06000036" => "Bracknell Forest",
"E06000037" => "West Berkshire",
"E06000038" => "Reading",
"E06000039" => "Slough",
"E06000040" => "Windsor and Maidenhead",
"E06000041" => "Wokingham",
"E06000042" => "Milton Keynes",
"E06000043" => "Brighton and Hove",
"E06000044" => "Portsmouth",
"E06000045" => "Southampton",
"E06000046" => "Isle of Wight",
"E06000047" => "County Durham",
"E06000049" => "Cheshire East",
"E06000050" => "Cheshire West and Chester",
"E06000051" => "Shropshire",
"E06000052" => "Cornwall",
"E06000053" => "Isles of Scilly",
"E06000054" => "Wiltshire",
"E06000055" => "Bedford",
"E06000056" => "Central Bedfordshire",
"E06000057" => "Northumberland",
"E06000058" => "Bournemouth, Christchurch and Poole",
"E06000059" => "Dorset",
"E06000060" => "Buckinghamshire",
"E07000008" => "Cambridge",
"E07000009" => "East Cambridgeshire",
"E07000010" => "Fenland",
"E07000011" => "Huntingdonshire",
"E07000012" => "South Cambridgeshire",
"E07000026" => "Allerdale",
"E07000027" => "Barrow-in-Furness",
"E07000028" => "Carlisle",
"E07000029" => "Copeland",
"E07000030" => "Eden",
"E07000031" => "South Lakeland",
"E07000032" => "Amber Valley",
"E07000033" => "Bolsover",
"E07000034" => "Chesterfield",
"E07000035" => "Derbyshire Dales",
"E07000036" => "Erewash",
"E07000037" => "High Peak",
"E07000038" => "North East Derbyshire",
"E07000039" => "South Derbyshire",
"E07000040" => "East Devon",
"E07000041" => "Exeter",
"E07000042" => "Mid Devon",
"E07000043" => "North Devon",
"E07000044" => "South Hams",
"E07000045" => "Teignbridge",
"E07000046" => "Torridge",
"E07000047" => "West Devon",
"E07000061" => "Eastbourne",
"E07000062" => "Hastings",
"E07000063" => "Lewes",
"E07000064" => "Rother",
"E07000065" => "Wealden",
"E07000066" => "Basildon",
"E07000067" => "Braintree",
"E07000068" => "Brentwood",
"E07000069" => "Castle Point",
"E07000070" => "Chelmsford",
"E07000071" => "Colchester",
"E07000072" => "Epping Forest",
"E07000073" => "Harlow",
"E07000074" => "Maldon",
"E07000075" => "Rochford",
"E07000076" => "Tendring",
"E07000077" => "Uttlesford",
"E07000078" => "Cheltenham",
"E07000079" => "Cotswold",
"E07000080" => "Forest of Dean",
"E07000081" => "Gloucester",
"E07000082" => "Stroud",
"E07000083" => "Tewkesbury",
"E07000084" => "Basingstoke and Deane",
"E07000085" => "East Hampshire",
"E07000086" => "Eastleigh",
"E07000087" => "Fareham",
"E07000088" => "Gosport",
"E07000089" => "Hart",
"E07000090" => "Havant",
"E07000091" => "New Forest",
"E07000092" => "Rushmoor",
"E07000093" => "Test Valley",
"E07000094" => "Winchester",
"E07000095" => "Broxbourne",
"E07000096" => "Dacorum",
"E07000098" => "Hertsmere",
"E07000099" => "North Hertfordshire",
"E07000102" => "Three Rivers",
"E07000103" => "Watford",
"E07000105" => "Ashford",
"E07000106" => "Canterbury",
"E07000107" => "Dartford",
"E07000108" => "Dover",
"E07000109" => "Gravesham",
"E07000110" => "Maidstone",
"E07000111" => "Sevenoaks",
"E07000112" => "Folkestone and Hythe",
"E07000113" => "Swale",
"E07000114" => "Thanet",
"E07000115" => "Tonbridge and Malling",
"E07000116" => "Tunbridge Wells",
"E07000117" => "Burnley",
"E07000118" => "Chorley",
"E07000119" => "Fylde",
"E07000120" => "Hyndburn",
"E07000121" => "Lancaster",
"E07000122" => "Pendle",
"E07000123" => "Preston",
"E07000124" => "Ribble Valley",
"E07000125" => "Rossendale",
"E07000126" => "South Ribble",
"E07000127" => "West Lancashire",
"E07000128" => "Wyre",
"E07000129" => "Blaby",
"E07000130" => "Charnwood",
"E07000131" => "Harborough",
"E07000132" => "Hinckley and Bosworth",
"E07000133" => "Melton",
"E07000134" => "North West Leicestershire",
"E07000135" => "Oadby and Wigston",
"E07000136" => "Boston",
"E07000137" => "East Lindsey",
"E07000138" => "Lincoln",
"E07000139" => "North Kesteven",
"E07000140" => "South Holland",
"E07000141" => "South Kesteven",
"E07000142" => "West Lindsey",
"E07000143" => "Breckland",
"E07000144" => "Broadland",
"E07000145" => "Great Yarmouth",
"E07000146" => "King’s Lynn and West Norfolk",
"E07000147" => "North Norfolk",
"E07000148" => "Norwich",
"E07000149" => "South Norfolk",
"E07000150" => "Corby",
"E07000151" => "Daventry",
"E07000152" => "East Northamptonshire",
"E07000153" => "Kettering",
"E07000154" => "Northampton",
"E07000155" => "South Northamptonshire",
"E07000156" => "Wellingborough",
"E07000163" => "Craven",
"E07000164" => "Hambleton",
"E07000165" => "Harrogate",
"E07000166" => "Richmondshire",
"E07000167" => "Ryedale",
"E07000168" => "Scarborough",
"E07000169" => "Selby",
"E07000170" => "Ashfield",
"E07000171" => "Bassetlaw",
"E07000172" => "Broxtowe",
"E07000173" => "Gedling",
"E07000174" => "Mansfield",
"E07000175" => "Newark and Sherwood",
"E07000176" => "Rushcliffe",
"E07000177" => "Cherwell",
"E07000178" => "Oxford",
"E07000179" => "South Oxfordshire",
"E07000180" => "Vale of White Horse",
"E07000181" => "West Oxfordshire",
"E07000187" => "Mendip",
"E07000188" => "Sedgemoor",
"E07000189" => "South Somerset",
"E07000192" => "Cannock Chase",
"E07000193" => "East Staffordshire",
"E07000194" => "Lichfield",
"E07000195" => "Newcastle-under-Lyme",
"E07000196" => "South Staffordshire",
"E07000197" => "Stafford",
"E07000198" => "Staffordshire Moorlands",
"E07000199" => "Tamworth",
"E07000200" => "Babergh",
"E07000202" => "Ipswich",
"E07000203" => "Mid Suffolk",
"E07000207" => "Elmbridge",
"E07000208" => "Epsom and Ewell",
"E07000209" => "Guildford",
"E07000210" => "Mole Valley",
"E07000211" => "Reigate and Banstead",
"E07000212" => "Runnymede",
"E07000213" => "Spelthorne",
"E07000214" => "Surrey Heath",
"E07000215" => "Tandridge",
"E07000216" => "Waverley",
"E07000217" => "Woking",
"E07000218" => "North Warwickshire",
"E07000219" => "Nuneaton and Bedworth",
"E07000220" => "Rugby",
"E07000221" => "Stratford-on-Avon",
"E07000222" => "Warwick",
"E07000223" => "Adur",
"E07000224" => "Arun",
"E07000225" => "Chichester",
"E07000226" => "Crawley",
"E07000227" => "Horsham",
"E07000228" => "Mid Sussex",
"E07000229" => "Worthing",
"E07000234" => "Bromsgrove",
"E07000235" => "Malvern Hills",
"E07000236" => "Redditch",
"E07000237" => "Worcester",
"E07000238" => "Wychavon",
"E07000239" => "Wyre Forest",
"E07000240" => "St Albans",
"E07000241" => "Welwyn Hatfield",
"E07000242" => "East Hertfordshire",
"E07000243" => "Stevenage",
"E07000244" => "East Suffolk",
"E07000245" => "West Suffolk",
"E07000246" => "Somerset West and Taunton",
"E08000001" => "Bolton",
"E08000002" => "Bury",
"E08000003" => "Manchester",
"E08000004" => "Oldham",
"E08000005" => "Rochdale",
"E08000006" => "Salford",
"E08000007" => "Stockport",
"E08000008" => "Tameside",
"E08000009" => "Trafford",
"E08000010" => "Wigan",
"E08000011" => "Knowsley",
"E08000012" => "Liverpool",
"E08000013" => "St. Helens",
"E08000014" => "Sefton",
"E08000015" => "Wirral",
"E08000016" => "Barnsley",
"E08000017" => "Doncaster",
"E08000018" => "Rotherham",
"E08000019" => "Sheffield",
"E08000021" => "Newcastle upon Tyne",
"E08000022" => "North Tyneside",
"E08000023" => "South Tyneside",
"E08000024" => "Sunderland",
"E08000025" => "Birmingham",
"E08000026" => "Coventry",
"E08000027" => "Dudley",
"E08000028" => "Sandwell",
"E08000029" => "Solihull",
"E08000030" => "Walsall",
"E08000031" => "Wolverhampton",
"E08000032" => "Bradford",
"E08000033" => "Calderdale",
"E08000034" => "Kirklees",
"E08000035" => "Leeds",
"E08000036" => "Wakefield",
"E08000037" => "Gateshead",
"E09000001" => "City of London",
"E09000002" => "Barking and Dagenham",
"E09000003" => "Barnet",
"E09000004" => "Bexley",
"E09000005" => "Brent",
"E09000006" => "Bromley",
"E09000007" => "Camden",
"E09000008" => "Croydon",
"E09000009" => "Ealing",
"E09000010" => "Enfield",
"E09000011" => "Greenwich",
"E09000012" => "Hackney",
"E09000013" => "Hammersmith and Fulham",
"E09000014" => "Haringey",
"E09000015" => "Harrow",
"E09000016" => "Havering",
"E09000017" => "Hillingdon",
"E09000018" => "Hounslow",
"E09000019" => "Islington",
"E09000020" => "Kensington and Chelsea",
"E09000021" => "Kingston upon Thames",
"E09000022" => "Lambeth",
"E09000023" => "Lewisham",
"E09000024" => "Merton",
"E09000025" => "Newham",
"E09000026" => "Redbridge",
"E09000027" => "Richmond upon Thames",
"E09000028" => "Southwark",
"E09000029" => "Sutton",
"E09000030" => "Tower Hamlets",
"E09000031" => "Waltham Forest",
"E09000032" => "Wandsworth",
"E09000033" => "Westminster",
"S12000017" => "Highland",
"W06000002" => "Gwynedd",
})
end
end

41
spec/models/form/sales/questions/property_wheelchair_accessible_spec.rb

@ -0,0 +1,41 @@
require "rails_helper"
RSpec.describe Form::Sales::Questions::PropertyWheelchairAccessible, type: :model do
subject(:question) { described_class.new(question_id, question_definition, page) }
let(:question_id) { nil }
let(:question_definition) { nil }
let(:page) { instance_double(Form::Page) }
it "has correct page" do
expect(question.page).to eq(page)
end
it "has the correct id" do
expect(question.id).to eq("wchair")
end
it "has the correct header" do
expect(question.header).to eq("Is the property build or adapted to wheelchair-user standards?")
end
it "has the correct check_answer_label" do
expect(question.check_answer_label).to eq("Property build or adapted to wheelchair-user standards")
end
it "has the correct type" do
expect(question.type).to eq("radio")
end
it "is not marked as derived" do
expect(question.derived?).to be false
end
it "has the correct answer_options" do
expect(question.answer_options).to eq({
"1" => { "value" => "Yes" },
"2" => { "value" => "No" },
"3" => { "value" => "Don't know" },
})
end
end

1
spec/models/form/sales/subsections/property_information_spec.rb

@ -18,6 +18,7 @@ RSpec.describe Form::Sales::Subsections::PropertyInformation, type: :model do
property_building_type
property_unit_type
property_local_authority
property_wheelchair_accessible
],
)
end

4
spec/models/form_handler_spec.rb

@ -52,14 +52,14 @@ RSpec.describe FormHandler do
it "is able to load a current sales form" do
form = form_handler.get_form("current_sales")
expect(form).to be_a(Form)
expect(form.pages.count).to eq(116)
expect(form.pages.count).to eq(117)
expect(form.name).to eq("2022_2023_sales")
end
it "is able to load a previous sales form" do
form = form_handler.get_form("previous_sales")
expect(form).to be_a(Form)
expect(form.pages.count).to eq(116)
expect(form.pages.count).to eq(117)
expect(form.name).to eq("2021_2022_sales")
end
end

Loading…
Cancel
Save